@@ -4,21 +4,45 @@ var fs = require('fs-extra'),
4
4
path = require ( 'path' ) ;
5
5
6
6
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
+ */
8
14
shuffle : function ( o ) {
9
15
/*eslint-disable curly*/
10
16
for ( var j , x , i = o . length ; i ; j = Math . floor ( Math . random ( ) * i ) , x = o [ -- i ] , o [ i ] = o [ j ] , o [ j ] = x ) ;
11
17
return o ;
12
18
} ,
13
19
20
+ /**
21
+ * Logs a message to the console with green text.
22
+ *
23
+ * @param {string } message
24
+ * @returns {string } message
25
+ */
14
26
logGreen : function ( message ) {
15
27
console . log ( '\x1b[32m' , message , '\x1b[0m' ) ;
16
28
} ,
17
29
30
+ /**
31
+ * Logs a message to the console with orange text.
32
+ *
33
+ * @param {string } message
34
+ * @returns {string } message
35
+ */
18
36
logOrange : function ( message ) {
19
37
console . log ( '\x1b[33m' , message , '\x1b[0m' ) ;
20
38
} ,
21
39
40
+ /**
41
+ * Logs a message to the console with red text.
42
+ *
43
+ * @param {string } message
44
+ * @returns {string } message
45
+ */
22
46
logRed : function ( message ) {
23
47
console . log ( '\x1b[41m' , message , '\x1b[0m' ) ;
24
48
} ,
@@ -60,15 +84,27 @@ var util = {
60
84
return obj2 ;
61
85
} ,
62
86
87
+ /**
88
+ * Determines whether or not an object is empty.
89
+ *
90
+ * @param {Object } obj
91
+ * @returns {Boolean }
92
+ */
63
93
isObjectEmpty : function ( obj ) {
64
94
for ( var prop in obj ) {
65
95
if ( obj . hasOwnProperty ( prop ) ) { return false ; }
66
96
}
67
97
return true ;
68
98
} ,
69
99
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
+ */
72
108
emptyDirectory : function ( dir , cleanDir ) {
73
109
var list = fs . readdirSync ( dir ) ;
74
110
for ( var i = 0 ; i < list . length ; i ++ ) {
0 commit comments