Repository navigation
Expand file tree
/
Copy pathnode-sim.js
More file actions
81 lines (61 loc) · 1.39 KB
/
Copy pathnode-sim.js
File metadata and controls
81 lines (61 loc) · 1.39 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
'use strict';
const promiseTypeRe = /^(?:function|object)$/;
const toString = Object.prototype.toString;
function is (obj, T, type) {
if (!obj) {
return false;
}
if (obj instanceof T) {
return true;
}
let t = toString.call(obj);
return t === type;
}
module.exports = {
// internal/util
customInspectSymbol: Symbol('inspector'),
isError (obj) {
return is(obj, Error, '[object Error]');
},
// process.binding('util') -- These are implemented in C++ in Node.js so "best"
// effort
getProxyDetails (obj) {
// Probably no good way to know if an object is a Proxy... TODO?
},
isArrayBuffer (obj) {
//TODO
},
isDataView (obj) {
//TODO
},
isDate (obj) {
return is(obj, Date, '[object Date]');
},
isMap (obj) {
return is(obj, Map, '[object Map]');
},
isMapIterator (obj) {
//TODO
},
isPromise (o) {
if (o && promiseTypeRe.test(typeof o) && typeof o.then === 'function') {
return true;
}
return false;
},
isRegExp (obj) {
return is(obj, RegExp, '[object RegExp]');
},
isSet (obj) {
return is(obj, Set, '[object Set]');
},
isSetIterator (obj) {
//TODO
},
isSharedArrayBuffer (obj) {
//TODO
},
isTypedArray (obj) {
//TODO
}
};