Skip to content

Commit c6c6ede

Browse files
Merge pull request #493 from brendanbowidas/dev
#492 add jsdoc comments to core/lib/utilities.js
2 parents aefb32a + e637108 commit c6c6ede

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

core/lib/utilities.js

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,45 @@ var fs = require('fs-extra'),
44
path = require('path');
55

66
var util = {
7-
// http://stackoverflow.com/questions/6274339/how-can-i-shuffle-an-array-in-javascript
7+
/**
8+
* Shuffles an array in place.
9+
* http://stackoverflow.com/questions/6274339/how-can-i-shuffle-an-array-in-javascript
10+
*
11+
* @param {Array} o
12+
* @returns {Array} o
13+
*/
814
shuffle: function (o) {
915
/*eslint-disable curly*/
1016
for (var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
1117
return o;
1218
},
1319

20+
/**
21+
* Logs a message to the console with green text.
22+
*
23+
* @param {string} message
24+
* @returns {string} message
25+
*/
1426
logGreen: function (message) {
1527
console.log('\x1b[32m', message, '\x1b[0m');
1628
},
1729

30+
/**
31+
* Logs a message to the console with orange text.
32+
*
33+
* @param {string} message
34+
* @returns {string} message
35+
*/
1836
logOrange: function (message) {
1937
console.log('\x1b[33m', message, '\x1b[0m');
2038
},
2139

40+
/**
41+
* Logs a message to the console with red text.
42+
*
43+
* @param {string} message
44+
* @returns {string} message
45+
*/
2246
logRed: function (message) {
2347
console.log('\x1b[41m', message, '\x1b[0m');
2448
},
@@ -60,15 +84,27 @@ var util = {
6084
return obj2;
6185
},
6286

87+
/**
88+
* Determines whether or not an object is empty.
89+
*
90+
* @param {Object} obj
91+
* @returns {Boolean}
92+
*/
6393
isObjectEmpty: function (obj) {
6494
for (var prop in obj) {
6595
if (obj.hasOwnProperty(prop)) { return false; }
6696
}
6797
return true;
6898
},
6999

70-
// recursively delete the contents of directory
71-
// adapted from https://gist.github.com/tkihira/2367067
100+
/**
101+
* Recursively delete the contents of directory.
102+
* Adapted from https://gist.github.com/tkihira/2367067
103+
*
104+
* @param {string} dir - directory to empty
105+
* @param {string} cleanDir - already empty directory
106+
* @returns {undefined}
107+
*/
72108
emptyDirectory: function (dir, cleanDir) {
73109
var list = fs.readdirSync(dir);
74110
for (var i = 0; i < list.length; i++) {

0 commit comments

Comments
 (0)