2
2
3
3
const {
4
4
Array,
5
+ ArrayBuffer,
6
+ ArrayBufferPrototype,
5
7
ArrayIsArray,
8
+ ArrayPrototype,
6
9
ArrayPrototypeFilter,
7
10
ArrayPrototypeForEach,
8
11
ArrayPrototypeIncludes,
@@ -29,6 +32,8 @@ const {
29
32
FunctionPrototypeSymbolHasInstance,
30
33
FunctionPrototypeToString,
31
34
JSONStringify,
35
+ Map,
36
+ MapPrototype,
32
37
MapPrototypeEntries,
33
38
MapPrototypeGetSize,
34
39
MathFloor,
@@ -68,6 +73,8 @@ const {
68
73
SafeMap,
69
74
SafeSet,
70
75
SafeStringIterator,
76
+ Set,
77
+ SetPrototype,
71
78
SetPrototypeGetSize,
72
79
SetPrototypeValues,
73
80
String,
@@ -93,6 +100,8 @@ const {
93
100
SymbolPrototypeValueOf,
94
101
SymbolToPrimitive,
95
102
SymbolToStringTag,
103
+ TypedArray,
104
+ TypedArrayPrototype,
96
105
TypedArrayPrototypeGetLength,
97
106
TypedArrayPrototypeGetSymbolToStringTag,
98
107
Uint8Array,
@@ -599,8 +608,13 @@ function isInstanceof(object, proto) {
599
608
600
609
// Special-case for some builtin prototypes in case their `constructor` property has been tampered.
601
610
const wellKnownPrototypes = new SafeMap ( ) ;
602
- wellKnownPrototypes . set ( ObjectPrototype , { name : 'Object' , constructor : Object } ) ;
611
+ wellKnownPrototypes . set ( ArrayPrototype , { name : 'Array' , constructor : Array } ) ;
612
+ wellKnownPrototypes . set ( ArrayBufferPrototype , { name : 'ArrayBuffer' , constructor : ArrayBuffer } ) ;
603
613
wellKnownPrototypes . set ( FunctionPrototype , { name : 'Function' , constructor : Function } ) ;
614
+ wellKnownPrototypes . set ( MapPrototype , { name : 'Map' , constructor : Map } ) ;
615
+ wellKnownPrototypes . set ( ObjectPrototype , { name : 'Object' , constructor : Object } ) ;
616
+ wellKnownPrototypes . set ( SetPrototype , { name : 'Set' , constructor : Set } ) ;
617
+ wellKnownPrototypes . set ( TypedArrayPrototype , { name : 'TypedArray' , constructor : TypedArray } ) ;
604
618
605
619
function getConstructorName ( obj , ctx , recurseTimes , protoProps ) {
606
620
let firstProto ;
@@ -825,12 +839,12 @@ function formatValue(ctx, value, recurseTimes, typedArray) {
825
839
// Filter out the util module, its inspect function is special.
826
840
maybeCustom !== inspect &&
827
841
// Also filter out any prototype objects using the circular check.
828
- ! ( value . constructor && value . constructor . prototype === value ) ) {
842
+ ObjectGetOwnPropertyDescriptor ( value , ' constructor' ) ?. value ?. prototype !== value ) {
829
843
// This makes sure the recurseTimes are reported as before while using
830
844
// a counter internally.
831
845
const depth = ctx . depth === null ? null : ctx . depth - recurseTimes ;
832
846
const isCrossContext =
833
- proxy !== undefined || ! ( context instanceof Object ) ;
847
+ proxy !== undefined || ! FunctionPrototypeSymbolHasInstance ( Object , context ) ;
834
848
const ret = FunctionPrototypeCall (
835
849
maybeCustom ,
836
850
context ,
0 commit comments