File tree 1 file changed +26
-2
lines changed
1 file changed +26
-2
lines changed Original file line number Diff line number Diff line change 35
35
nodeInspect = false
36
36
}
37
37
38
- const constructorMap = new WeakMap ( )
38
+ function FakeMap ( ) {
39
+ // eslint-disable-next-line prefer-template
40
+ this . key = 'chai/loupe__' + Math . random ( ) + Date . now ( )
41
+ }
42
+ FakeMap . prototype = {
43
+ // eslint-disable-next-line object-shorthand
44
+ get : function get ( key ) {
45
+ return key [ this . key ]
46
+ } ,
47
+ // eslint-disable-next-line object-shorthand
48
+ has : function has ( key ) {
49
+ return this . key in key
50
+ } ,
51
+ // eslint-disable-next-line object-shorthand
52
+ set : function set ( key , value ) {
53
+ if ( Object . isExtensible ( key ) ) {
54
+ Object . defineProperty ( key , this . key , {
55
+ // eslint-disable-next-line object-shorthand
56
+ value : value ,
57
+ configurable : true ,
58
+ } )
59
+ }
60
+ } ,
61
+ }
62
+ const constructorMap = new ( typeof WeakMap === 'function' ? WeakMap : FakeMap ) ( )
39
63
const stringTagMap = { }
40
64
const baseTypesMap = {
41
65
undefined : ( value , options ) => options . stylize ( 'undefined' , 'undefined' ) ,
@@ -178,7 +202,7 @@ export function registerConstructor(constructor, inspector) {
178
202
if ( constructorMap . has ( constructor ) ) {
179
203
return false
180
204
}
181
- constructorMap . add ( constructor , inspector )
205
+ constructorMap . set ( constructor , inspector )
182
206
return true
183
207
}
184
208
You can’t perform that action at this time.
0 commit comments