-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlazy.utils.js
44 lines (34 loc) · 913 Bytes
/
lazy.utils.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
class LazyTypes{
constructor(){
if(!lazyTypesInstance){
lazyTypesInstance = this;
}
return lazyTypesInstance
}
getFullType(value){
return Object.prototype.toString.call(value).split(" ").pop().split("]")[0];
}
isArray(value){
return this.getFullType(value) === "Array";
}
isObject(value){
return this.getFullType(value) === "Object";
}
isString(value){
return this.getFullType(value) === "String";
}
isNumber(value){
return this.getFullType(value) === "Number";
}
isBoolean(value){
return this.getFullType(value) === "Boolean";
}
isFunction(value){
let type = this.getFullType(value);
return type === "Function" || type === "AsyncFunction";
}
}
var lazyTypesInstance = new LazyTypes();
module.exports = {
LazyTypes: lazyTypesInstance
}