@@ -49,97 +49,6 @@ const warning = log.warning.bind(log);
49
49
*/
50
50
const error = log . error . bind ( log ) ;
51
51
52
- /**
53
- * Shuffles an array in place.
54
- * http://stackoverflow.com/questions/6274339/how-can-i-shuffle-an-array-in-javascript
55
- *
56
- * @param {Array } o
57
- * @returns {Array } o
58
- */
59
- const shuffle = function ( o ) {
60
- /*eslint-disable curly*/
61
- for ( var j , x , i = o . length ; i ; j = Math . floor ( Math . random ( ) * i ) , x = o [ -- i ] , o [ i ] = o [ j ] , o [ j ] = x ) ;
62
- return o ;
63
- } ;
64
-
65
- /**
66
- * Recursively merge properties of two objects.
67
- *
68
- * @param {Object } obj1 If obj1 has properties obj2 doesn't, add to obj2.
69
- * @param {Object } obj2 This object's properties have priority over obj1.
70
- * @returns {Object } obj2
71
- */
72
- const mergeData = function ( obj1 , obj2 ) {
73
- /*eslint-disable no-param-reassign, guard-for-in*/
74
- if ( typeof obj2 === 'undefined' ) {
75
- obj2 = { } ;
76
- }
77
- for ( var p in obj1 ) {
78
- try {
79
- // Only recurse if obj1[p] is an object.
80
- if ( obj1 [ p ] . constructor === Object ) {
81
- // Requires 2 objects as params; create obj2[p] if undefined.
82
- if ( typeof obj2 [ p ] === 'undefined' ) {
83
- obj2 [ p ] = { } ;
84
- }
85
- obj2 [ p ] = mergeData ( obj1 [ p ] , obj2 [ p ] ) ;
86
-
87
- // Pop when recursion meets a non-object. If obj1[p] is a non-object,
88
- // only copy to undefined obj2[p]. This way, obj2 maintains priority.
89
- } else if ( typeof obj2 [ p ] === 'undefined' ) {
90
- obj2 [ p ] = obj1 [ p ] ;
91
- }
92
- } catch ( e ) {
93
- // Property in destination object not set; create it and set its value.
94
- if ( typeof obj2 [ p ] === 'undefined' ) {
95
- obj2 [ p ] = obj1 [ p ] ;
96
- }
97
- }
98
- }
99
- return obj2 ;
100
- } ;
101
-
102
- /**
103
- * Determines whether or not an object is empty.
104
- *
105
- * @param {Object } obj
106
- * @returns {Boolean }
107
- */
108
- const isObjectEmpty = function ( obj ) {
109
- for ( var prop in obj ) {
110
- if ( obj . hasOwnProperty ( prop ) ) { return false ; }
111
- }
112
- return true ;
113
- } ;
114
-
115
- /**
116
- * Recursively delete the contents of directory.
117
- * Adapted from https://gist.github.com/tkihira/2367067
118
- *
119
- * @param {string } dir - directory to empty
120
- * @param {string } cleanDir - already empty directory
121
- * @returns {undefined }
122
- */
123
- const emptyDirectory = function ( dir , cleanDir ) {
124
- var list = fs . readdirSync ( dir ) ;
125
- for ( var i = 0 ; i < list . length ; i ++ ) {
126
- var filename = path . join ( dir , list [ i ] ) ;
127
- var stat = fs . statSync ( filename ) ;
128
-
129
- if ( filename === "." || filename === ".." ) {
130
- // pass these files
131
- } else if ( stat . isDirectory ( ) ) {
132
- this . emptyDirectory ( filename ) ;
133
- } else {
134
- // rm fiilename
135
- fs . unlinkSync ( filename ) ;
136
- }
137
- }
138
- if ( cleanDir ) {
139
- fs . rmdirSync ( dir ) ;
140
- }
141
- } ;
142
-
143
52
/**
144
53
* Useful for reporting errors in .catch() on Promises
145
54
* @param {string } - a message to report
@@ -158,9 +67,5 @@ module.exports = {
158
67
warning,
159
68
error,
160
69
log,
161
- shuffle,
162
- mergeData,
163
- isObjectEmpty,
164
- emptyDirectory,
165
70
reportError
166
71
} ;
0 commit comments