-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.js
44 lines (40 loc) · 1 KB
/
util.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
((root, factory) => {
root["_"] = factory();
})(this, () => {
return {
handleError(msg) {
console.error(msg);
},
clone(objectToBeCloned) {
// Basis.
if (!(objectToBeCloned instanceof Object)) {
return objectToBeCloned;
}
var objectClone;
var Constructor = objectToBeCloned.constructor;
switch (Constructor) {
case RegExp:
objectClone = new Constructor(objectToBeCloned);
break;
case Date:
objectClone = new Constructor(objectToBeCloned.getTime());
break;
default:
objectClone = new Constructor();
}
for (var prop in objectToBeCloned) {
objectClone[prop] = clone(objectToBeCloned[prop]);
}
return objectClone;
},
isObject(data) {
return Object.prototype.toString.call(data) === '[object Object]';
},
show(target) {
target.style.display = 'block';
},
hide(target) {
target.style.display = 'none';
}
}
});