| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 010dd91 commit 1c7396b
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,6 +10,7 @@ const notCircular = {}; | |||
| 10 | 10 | notCircular.circular = {}; | |
| 11 | 11 | ||
| 12 | 12 | const primValues = { | |
| 13 | + 'null_prototype': { __proto__: null }, | ||
| 13 | 14 | 'string': 'abcdef', | |
| 14 | 15 | 'number': 1_000, | |
| 15 | 16 | 'boolean': true, | |
@@ -24,6 +25,7 @@ const primValues = { | |||
| 24 | 25 | }; | |
| 25 | 26 | ||
| 26 | 27 | const primValues2 = { | |
| 28 | + 'null_prototype': { __proto__: null }, | ||
| 27 | 29 | 'object': { property: 'abcdef' }, | |
| 28 | 30 | 'array': [1, 2, 3], | |
| 29 | 31 | 'set_object': new Set([[1]]), | |
@@ -35,6 +37,7 @@ const primValues2 = { | |||
| 35 | 37 | }; | |
| 36 | 38 | ||
| 37 | 39 | const primValuesUnequal = { | |
| 40 | + 'null_prototype': { __proto__: { __proto__: null } }, | ||
| 38 | 41 | 'string': 'abcdez', | |
| 39 | 42 | 'number': 1_001, | |
| 40 | 43 | 'boolean': false, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,14 +1,31 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | 3 | const { | |
| 4 | + Array, | ||
| 5 | + ArrayBuffer, | ||
| 4 | 6 | ArrayIsArray, | |
| 5 | 7 | ArrayPrototypeFilter, | |
| 6 | 8 | ArrayPrototypePush, | |
| 9 | + BigInt, | ||
| 10 | + BigInt64Array, | ||
| 7 | 11 | BigIntPrototypeValueOf, | |
| 12 | + BigUint64Array, | ||
| 13 | + Boolean, | ||
| 8 | 14 | BooleanPrototypeValueOf, | |
| 15 | + DataView, | ||
| 16 | + Date, | ||
| 9 | 17 | DatePrototypeGetTime, | |
| 10 | 18 | Error, | |
| 19 | + Float32Array, | ||
| 20 | + Float64Array, | ||
| 21 | + Function, | ||
| 22 | + Int16Array, | ||
| 23 | + Int32Array, | ||
| 24 | + Int8Array, | ||
| 25 | + Map, | ||
| 26 | + Number, | ||
| 11 | 27 | NumberPrototypeValueOf, | |
| 28 | + Object, | ||
| 12 | 29 | ObjectGetOwnPropertyDescriptor, | |
| 13 | 30 | ObjectGetOwnPropertySymbols: getOwnSymbols, | |
| 14 | 31 | ObjectGetPrototypeOf, | |
@@ -17,18 +34,67 @@ const { | |||
| 17 | 34 | ObjectPrototypeHasOwnProperty: hasOwn, | |
| 18 | 35 | ObjectPrototypePropertyIsEnumerable: hasEnumerable, | |
| 19 | 36 | ObjectPrototypeToString, | |
| 37 | + Promise, | ||
| 38 | + RegExp, | ||
| 20 | 39 | SafeSet, | |
| 40 | + Set, | ||
| 41 | + String, | ||
| 21 | 42 | StringPrototypeValueOf, | |
| 43 | + Symbol, | ||
| 22 | 44 | SymbolPrototypeValueOf, | |
| 23 | 45 | TypedArrayPrototypeGetByteLength: getByteLength, | |
| 24 | 46 | TypedArrayPrototypeGetSymbolToStringTag, | |
| 47 | + Uint16Array, | ||
| 48 | + Uint32Array, | ||
| 25 | 49 | Uint8Array, | |
| 50 | + Uint8ClampedArray, | ||
| 51 | + WeakMap, | ||
| 52 | + WeakSet, | ||
| 53 | + globalThis: { Float16Array }, | ||
| 26 | 54 | } = primordials; | |
| 27 | 55 | ||
| 28 | 56 | const { compare } = internalBinding('buffer'); | |
| 29 | 57 | const assert = require('internal/assert'); | |
| 30 | 58 | const { isError } = require('internal/util'); | |
| 31 | 59 | const { isURL } = require('internal/url'); | |
| 60 | + const { Buffer } = require('buffer'); | ||
| 61 | + | ||
| 62 | + const wellKnownConstructors = new SafeSet() | ||
| 63 | + .add(Array) | ||
| 64 | + .add(ArrayBuffer) | ||
| 65 | + .add(BigInt) | ||
| 66 | + .add(BigInt64Array) | ||
| 67 | + .add(BigUint64Array) | ||
| 68 | + .add(Boolean) | ||
| 69 | + .add(Buffer) | ||
| 70 | + .add(DataView) | ||
| 71 | + .add(Date) | ||
| 72 | + .add(Error) | ||
| 73 | + .add(Float32Array) | ||
| 74 | + .add(Float64Array) | ||
| 75 | + .add(Function) | ||
| 76 | + .add(Int16Array) | ||
| 77 | + .add(Int32Array) | ||
| 78 | + .add(Int8Array) | ||
| 79 | + .add(Map) | ||
| 80 | + .add(Number) | ||
| 81 | + .add(Object) | ||
| 82 | + .add(Promise) | ||
| 83 | + .add(RegExp) | ||
| 84 | + .add(Set) | ||
| 85 | + .add(String) | ||
| 86 | + .add(Symbol) | ||
| 87 | + .add(Uint16Array) | ||
| 88 | + .add(Uint32Array) | ||
| 89 | + .add(Uint8Array) | ||
| 90 | + .add(Uint8ClampedArray) | ||
| 91 | + .add(WeakMap) | ||
| 92 | + .add(WeakSet); | ||
| 93 | + | ||
| 94 | + if (Float16Array) { // TODO(BridgeAR): Remove when regularly supported | ||
| 95 | + wellKnownConstructors.add(Float16Array); | ||
| 96 | + } | ||
| 97 | + | ||
| 32 | 98 | const types = require('internal/util/types'); | |
| 33 | 99 | const { | |
| 34 | 100 | isAnyArrayBuffer, | |
@@ -199,11 +265,15 @@ function innerDeepEqual(val1, val2, mode, memos) { | |||
| 199 | 265 | } | |
| 200 | 266 | ||
| 201 | 267 | function objectComparisonStart(val1, val2, mode, memos) { | |
| 202 | - if (mode === kStrict && | ||
| 203 | - (val1.constructor !== val2.constructor || | ||
| 204 | - (val1.constructor === undefined && | ||
| 205 | - ObjectGetPrototypeOf(val1) !== ObjectGetPrototypeOf(val2)))) { | ||
| 206 | - return false; | ||
| 268 | + if (mode === kStrict) { | ||
| 269 | + if (wellKnownConstructors.has(val1.constructor) || | ||
| 270 | + (val1.constructor !== undefined && !hasOwn(val1, 'constructor'))) { | ||
| 271 | + if (val1.constructor !== val2.constructor) { | ||
| 272 | + return false; | ||
| 273 | + } | ||
| 274 | + } else if (ObjectGetPrototypeOf(val1) !== ObjectGetPrototypeOf(val2)) { | ||
| 275 | + return false; | ||
| 276 | + } | ||
| 207 | 277 | } | |
| 208 | 278 | ||
| 209 | 279 | const val1Tag = ObjectPrototypeToString(val1); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -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) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments