@@ -20,10 +20,18 @@ const {
20
20
ArrayPrototypeSplice,
21
21
ArrayPrototypeUnshift,
22
22
BigIntPrototypeValueOf,
23
+ Boolean,
24
+ BooleanPrototype,
23
25
BooleanPrototypeValueOf,
26
+ DataView,
27
+ DataViewPrototype,
28
+ Date,
29
+ DatePrototype,
24
30
DatePrototypeGetTime,
25
31
DatePrototypeToISOString,
26
32
DatePrototypeToString,
33
+ Error,
34
+ ErrorPrototype,
27
35
ErrorPrototypeToString,
28
36
Function,
29
37
FunctionPrototype,
@@ -47,6 +55,7 @@ const {
47
55
NumberIsNaN,
48
56
NumberParseFloat,
49
57
NumberParseInt,
58
+ NumberPrototype,
50
59
NumberPrototypeToString,
51
60
NumberPrototypeValueOf,
52
61
Object,
@@ -63,9 +72,12 @@ const {
63
72
ObjectPrototypePropertyIsEnumerable,
64
73
ObjectSeal,
65
74
ObjectSetPrototypeOf,
75
+ Promise,
76
+ PromisePrototype,
66
77
ReflectApply,
67
78
ReflectOwnKeys,
68
79
RegExp,
80
+ RegExpPrototype,
69
81
RegExpPrototypeExec,
70
82
RegExpPrototypeSymbolReplace,
71
83
RegExpPrototypeSymbolSplit,
@@ -78,6 +90,7 @@ const {
78
90
SetPrototypeGetSize,
79
91
SetPrototypeValues,
80
92
String,
93
+ StringPrototype,
81
94
StringPrototypeCharCodeAt,
82
95
StringPrototypeCodePointAt,
83
96
StringPrototypeEndsWith,
@@ -106,6 +119,10 @@ const {
106
119
TypedArrayPrototypeGetLength,
107
120
TypedArrayPrototypeGetSymbolToStringTag,
108
121
Uint8Array,
122
+ WeakMap,
123
+ WeakMapPrototype,
124
+ WeakSet,
125
+ WeakSetPrototype,
109
126
globalThis,
110
127
uncurryThis,
111
128
} = primordials ;
@@ -608,21 +625,31 @@ function isInstanceof(object, proto) {
608
625
}
609
626
610
627
// Special-case for some builtin prototypes in case their `constructor` property has been tampered.
611
- const wellKnownPrototypes = new SafeMap ( ) ;
612
- wellKnownPrototypes . set ( ArrayPrototype , { name : 'Array' , constructor : Array } ) ;
613
- wellKnownPrototypes . set ( ArrayBufferPrototype , { name : 'ArrayBuffer' , constructor : ArrayBuffer } ) ;
614
- wellKnownPrototypes . set ( FunctionPrototype , { name : 'Function' , constructor : Function } ) ;
615
- wellKnownPrototypes . set ( MapPrototype , { name : 'Map' , constructor : Map } ) ;
616
- wellKnownPrototypes . set ( ObjectPrototype , { name : 'Object' , constructor : Object } ) ;
617
- wellKnownPrototypes . set ( SetPrototype , { name : 'Set' , constructor : Set } ) ;
618
- wellKnownPrototypes . set ( TypedArrayPrototype , { name : 'TypedArray' , constructor : TypedArray } ) ;
628
+ const wellKnownPrototypes = new SafeMap ( )
629
+ . set ( ArrayPrototype , { name : 'Array' , constructor : Array } )
630
+ . set ( ArrayBufferPrototype , { name : 'ArrayBuffer' , constructor : ArrayBuffer } )
631
+ . set ( FunctionPrototype , { name : 'Function' , constructor : Function } )
632
+ . set ( MapPrototype , { name : 'Map' , constructor : Map } )
633
+ . set ( SetPrototype , { name : 'Set' , constructor : Set } )
634
+ . set ( ObjectPrototype , { name : 'Object' , constructor : Object } )
635
+ . set ( TypedArrayPrototype , { name : 'TypedArray' , constructor : TypedArray } )
636
+ . set ( RegExpPrototype , { name : 'RegExp' , constructor : RegExp } )
637
+ . set ( DatePrototype , { name : 'Date' , constructor : Date } )
638
+ . set ( DataViewPrototype , { name : 'DataView' , constructor : DataView } )
639
+ . set ( ErrorPrototype , { name : 'Error' , constructor : Error } )
640
+ . set ( BooleanPrototype , { name : 'Boolean' , constructor : Boolean } )
641
+ . set ( NumberPrototype , { name : 'Number' , constructor : Number } )
642
+ . set ( StringPrototype , { name : 'String' , constructor : String } )
643
+ . set ( PromisePrototype , { name : 'Promise' , constructor : Promise } )
644
+ . set ( WeakMapPrototype , { name : 'WeakMap' , constructor : WeakMap } )
645
+ . set ( WeakSetPrototype , { name : 'WeakSet' , constructor : WeakSet } ) ;
619
646
620
647
function getConstructorName ( obj , ctx , recurseTimes , protoProps ) {
621
648
let firstProto ;
622
649
const tmp = obj ;
623
650
while ( obj || isUndetectableObject ( obj ) ) {
624
651
const wellKnownPrototypeNameAndConstructor = wellKnownPrototypes . get ( obj ) ;
625
- if ( wellKnownPrototypeNameAndConstructor != null ) {
652
+ if ( wellKnownPrototypeNameAndConstructor !== undefined ) {
626
653
const { name, constructor } = wellKnownPrototypeNameAndConstructor ;
627
654
if ( FunctionPrototypeSymbolHasInstance ( constructor , tmp ) ) {
628
655
if ( protoProps !== undefined && firstProto !== obj ) {
0 commit comments