Skip to content

Commit ecb0291

Browse files
committed
Remove unused functions from core/lib/utilities.js
1 parent 7390846 commit ecb0291

File tree

1 file changed

+0
-95
lines changed

1 file changed

+0
-95
lines changed

core/lib/utilities.js

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -49,97 +49,6 @@ const warning = log.warning.bind(log);
4949
*/
5050
const error = log.error.bind(log);
5151

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-
14352
/**
14453
* Useful for reporting errors in .catch() on Promises
14554
* @param {string} - a message to report
@@ -158,9 +67,5 @@ module.exports = {
15867
warning,
15968
error,
16069
log,
161-
shuffle,
162-
mergeData,
163-
isObjectEmpty,
164-
emptyDirectory,
16570
reportError
16671
};

0 commit comments

Comments
 (0)