| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,7 +35,6 @@ const { | |||
| 35 | 35 | ObjectCreate, | |
| 36 | 36 | ObjectDefineProperties, | |
| 37 | 37 | ObjectDefineProperty, | |
| 38 | - ObjectGetOwnPropertyDescriptor, | ||
| 39 | 38 | ObjectSetPrototypeOf, | |
| 40 | 39 | StringPrototypeCharCodeAt, | |
| 41 | 40 | StringPrototypeReplace, | |
@@ -44,12 +43,11 @@ const { | |||
| 44 | 43 | StringPrototypeTrim, | |
| 45 | 44 | SymbolSpecies, | |
| 46 | 45 | SymbolToPrimitive, | |
| 47 | - TypedArrayPrototype, | ||
| 46 | + TypedArrayPrototypeGetByteLength, | ||
| 48 | 47 | TypedArrayPrototypeFill, | |
| 49 | 48 | TypedArrayPrototypeSet, | |
| 50 | 49 | Uint8Array, | |
| 51 | 50 | Uint8ArrayPrototype, | |
| 52 | - uncurryThis, | ||
| 53 | 51 | } = primordials; | |
| 54 | 52 | ||
| 55 | 53 | const { | |
@@ -117,10 +115,6 @@ const { | |||
| 117 | 115 | createUnsafeBuffer | |
| 118 | 116 | } = require('internal/buffer'); | |
| 119 | 117 | ||
| 120 | - const TypedArrayProto_byteLength = uncurryThis( | ||
| 121 | - ObjectGetOwnPropertyDescriptor(TypedArrayPrototype, | ||
| 122 | - 'byteLength').get); | ||
| 123 | - | ||
| 124 | 118 | FastBuffer.prototype.constructor = Buffer; | |
| 125 | 119 | Buffer.prototype = FastBuffer.prototype; | |
| 126 | 120 | addBufferPrototypeMethods(Buffer.prototype); | |
@@ -1015,7 +1009,7 @@ function _fill(buf, value, offset, end, encoding) { | |||
| 1015 | 1009 | ||
| 1016 | 1010 | if (typeof value === 'number') { | |
| 1017 | 1011 | // OOB check | |
| 1018 | - const byteLen = TypedArrayProto_byteLength(buf); | ||
| 1012 | + const byteLen = TypedArrayPrototypeGetByteLength(buf); | ||
| 1019 | 1013 | const fillLength = end - offset; | |
| 1020 | 1014 | if (offset > end || fillLength + offset > byteLen) | |
| 1021 | 1015 | throw new ERR_BUFFER_OUT_OF_BOUNDS(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,44 +30,63 @@ function copyProps(src, dest) { | |||
| 30 | 30 | } | |
| 31 | 31 | } | |
| 32 | 32 | ||
| 33 | + function getNewKey(key) { | ||
| 34 | + return typeof key === 'symbol' ? | ||
| 35 | + `Symbol${key.description[7].toUpperCase()}${key.description.slice(8)}` : | ||
| 36 | + `${key[0].toUpperCase()}${key.slice(1)}`; | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + function copyAccessor(dest, prefix, key, { enumerable, get, set }) { | ||
| 40 | + Reflect.defineProperty(dest, `${prefix}Get${key}`, { | ||
| 41 | + value: uncurryThis(get), | ||
| 42 | + enumerable | ||
| 43 | + }); | ||
| 44 | + if (set !== undefined) { | ||
| 45 | + Reflect.defineProperty(dest, `${prefix}Set${key}`, { | ||
| 46 | + value: uncurryThis(set), | ||
| 47 | + enumerable | ||
| 48 | + }); | ||
| 49 | + } | ||
| 50 | + } | ||
| 51 | + | ||
| 33 | 52 | function copyPropsRenamed(src, dest, prefix) { | |
| 34 | 53 | for (const key of Reflect.ownKeys(src)) { | |
| 35 | - if (typeof key === 'string') { | ||
| 36 | - Reflect.defineProperty( | ||
| 37 | - dest, | ||
| 38 | - `${prefix}${key[0].toUpperCase()}${key.slice(1)}`, | ||
| 39 | - Reflect.getOwnPropertyDescriptor(src, key)); | ||
| 54 | + const newKey = getNewKey(key); | ||
| 55 | + const desc = Reflect.getOwnPropertyDescriptor(src, key); | ||
| 56 | + if ('get' in desc) { | ||
| 57 | + copyAccessor(dest, prefix, newKey, desc); | ||
| 58 | + } else { | ||
| 59 | + Reflect.defineProperty(dest, `${prefix}${newKey}`, desc); | ||
| 40 | 60 | } | |
| 41 | 61 | } | |
| 42 | 62 | } | |
| 43 | 63 | ||
| 44 | 64 | function copyPropsRenamedBound(src, dest, prefix) { | |
| 45 | 65 | for (const key of Reflect.ownKeys(src)) { | |
| 46 | - if (typeof key === 'string') { | ||
| 47 | - const desc = Reflect.getOwnPropertyDescriptor(src, key); | ||
| 66 | + const newKey = getNewKey(key); | ||
| 67 | + const desc = Reflect.getOwnPropertyDescriptor(src, key); | ||
| 68 | + if ('get' in desc) { | ||
| 69 | + copyAccessor(dest, prefix, newKey, desc); | ||
| 70 | + } else { | ||
| 48 | 71 | if (typeof desc.value === 'function') { | |
| 49 | 72 | desc.value = desc.value.bind(src); | |
| 50 | 73 | } | |
| 51 | - Reflect.defineProperty( | ||
| 52 | - dest, | ||
| 53 | - `${prefix}${key[0].toUpperCase()}${key.slice(1)}`, | ||
| 54 | - desc | ||
| 55 | - ); | ||
| 74 | + Reflect.defineProperty(dest, `${prefix}${newKey}`, desc); | ||
| 56 | 75 | } | |
| 57 | 76 | } | |
| 58 | 77 | } | |
| 59 | 78 | ||
| 60 | 79 | function copyPrototype(src, dest, prefix) { | |
| 61 | 80 | for (const key of Reflect.ownKeys(src)) { | |
| 62 | - if (typeof key === 'string') { | ||
| 63 | - const desc = Reflect.getOwnPropertyDescriptor(src, key); | ||
| 81 | + const newKey = getNewKey(key); | ||
| 82 | + const desc = Reflect.getOwnPropertyDescriptor(src, key); | ||
| 83 | + if ('get' in desc) { | ||
| 84 | + copyAccessor(dest, prefix, newKey, desc); | ||
| 85 | + } else { | ||
| 64 | 86 | if (typeof desc.value === 'function') { | |
| 65 | 87 | desc.value = uncurryThis(desc.value); | |
| 66 | 88 | } | |
| 67 | - Reflect.defineProperty( | ||
| 68 | - dest, | ||
| 69 | - `${prefix}${key[0].toUpperCase()}${key.slice(1)}`, | ||
| 70 | - desc); | ||
| 89 | + Reflect.defineProperty(dest, `${prefix}${newKey}`, desc); | ||
| 71 | 90 | } | |
| 72 | 91 | } | |
| 73 | 92 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,7 +20,7 @@ const { | |||
| 20 | 20 | Int32Array, | |
| 21 | 21 | JSONStringify, | |
| 22 | 22 | Map, | |
| 23 | - MapPrototype, | ||
| 23 | + MapPrototypeGetSize, | ||
| 24 | 24 | MapPrototypeEntries, | |
| 25 | 25 | MathFloor, | |
| 26 | 26 | MathMax, | |
@@ -50,15 +50,15 @@ const { | |||
| 50 | 50 | RegExp, | |
| 51 | 51 | RegExpPrototypeToString, | |
| 52 | 52 | Set, | |
| 53 | - SetPrototype, | ||
| 53 | + SetPrototypeGetSize, | ||
| 54 | 54 | SetPrototypeValues, | |
| 55 | 55 | String, | |
| 56 | 56 | StringPrototypeValueOf, | |
| 57 | 57 | SymbolPrototypeToString, | |
| 58 | 58 | SymbolPrototypeValueOf, | |
| 59 | 59 | SymbolIterator, | |
| 60 | 60 | SymbolToStringTag, | |
| 61 | - TypedArrayPrototype, | ||
| 61 | + TypedArrayPrototypeGetLength, | ||
| 62 | 62 | Uint16Array, | |
| 63 | 63 | Uint32Array, | |
| 64 | 64 | Uint8Array, | |
@@ -137,13 +137,6 @@ const assert = require('internal/assert'); | |||
| 137 | 137 | ||
| 138 | 138 | const { NativeModule } = require('internal/bootstrap/loaders'); | |
| 139 | 139 | ||
| 140 | - const setSizeGetter = uncurryThis( | ||
| 141 | - ObjectGetOwnPropertyDescriptor(SetPrototype, 'size').get); | ||
| 142 | - const mapSizeGetter = uncurryThis( | ||
| 143 | - ObjectGetOwnPropertyDescriptor(MapPrototype, 'size').get); | ||
| 144 | - const typedArraySizeGetter = uncurryThis( | ||
| 145 | - ObjectGetOwnPropertyDescriptor(TypedArrayPrototype, 'length').get); | ||
| 146 | - | ||
| 147 | 140 | let hexSlice; | |
| 148 | 141 | ||
| 149 | 142 | const builtInObjects = new Set( | |
@@ -854,7 +847,7 @@ function formatRaw(ctx, value, recurseTimes, typedArray) { | |||
| 854 | 847 | extrasType = kArrayExtrasType; | |
| 855 | 848 | formatter = formatArray; | |
| 856 | 849 | } else if (isSet(value)) { | |
| 857 | - const size = setSizeGetter(value); | ||
| 850 | + const size = SetPrototypeGetSize(value); | ||
| 858 | 851 | const prefix = getPrefix(constructor, tag, 'Set', `(${size})`); | |
| 859 | 852 | keys = getKeys(value, ctx.showHidden); | |
| 860 | 853 | formatter = constructor !== null ? | |
@@ -864,7 +857,7 @@ function formatRaw(ctx, value, recurseTimes, typedArray) { | |||
| 864 | 857 | return `${prefix}{}`; | |
| 865 | 858 | braces = [`${prefix}{`, '}']; | |
| 866 | 859 | } else if (isMap(value)) { | |
| 867 | - const size = mapSizeGetter(value); | ||
| 860 | + const size = MapPrototypeGetSize(value); | ||
| 868 | 861 | const prefix = getPrefix(constructor, tag, 'Map', `(${size})`); | |
| 869 | 862 | keys = getKeys(value, ctx.showHidden); | |
| 870 | 863 | formatter = constructor !== null ? | |
@@ -883,7 +876,7 @@ function formatRaw(ctx, value, recurseTimes, typedArray) { | |||
| 883 | 876 | // Reconstruct the array information. | |
| 884 | 877 | bound = new constr(value); | |
| 885 | 878 | } | |
| 886 | - const size = typedArraySizeGetter(value); | ||
| 879 | + const size = TypedArrayPrototypeGetLength(value); | ||
| 887 | 880 | const prefix = getPrefix(constructor, tag, fallback, `(${size})`); | |
| 888 | 881 | braces = [`${prefix}[`, ']']; | |
| 889 | 882 | if (value.length === 0 && keys.length === 0 && !ctx.showHidden) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,63 +2,55 @@ | |||
| 2 | 2 | ||
| 3 | 3 | const { | |
| 4 | 4 | ArrayBufferIsView, | |
| 5 | - ObjectGetOwnPropertyDescriptor, | ||
| 6 | - SymbolToStringTag, | ||
| 7 | - TypedArrayPrototype, | ||
| 8 | - uncurryThis, | ||
| 5 | + TypedArrayPrototypeGetSymbolToStringTag, | ||
| 9 | 6 | } = primordials; | |
| 10 | 7 | ||
| 11 | - const TypedArrayProto_toStringTag = | ||
| 12 | - uncurryThis( | ||
| 13 | - ObjectGetOwnPropertyDescriptor(TypedArrayPrototype, | ||
| 14 | - SymbolToStringTag).get); | ||
| 15 | - | ||
| 16 | 8 | function isTypedArray(value) { | |
| 17 | - return TypedArrayProto_toStringTag(value) !== undefined; | ||
| 9 | + return TypedArrayPrototypeGetSymbolToStringTag(value) !== undefined; | ||
| 18 | 10 | } | |
| 19 | 11 | ||
| 20 | 12 | function isUint8Array(value) { | |
| 21 | - return TypedArrayProto_toStringTag(value) === 'Uint8Array'; | ||
| 13 | + return TypedArrayPrototypeGetSymbolToStringTag(value) === 'Uint8Array'; | ||
| 22 | 14 | } | |
| 23 | 15 | ||
| 24 | 16 | function isUint8ClampedArray(value) { | |
| 25 | - return TypedArrayProto_toStringTag(value) === 'Uint8ClampedArray'; | ||
| 17 | + return TypedArrayPrototypeGetSymbolToStringTag(value) === 'Uint8ClampedArray'; | ||
| 26 | 18 | } | |
| 27 | 19 | ||
| 28 | 20 | function isUint16Array(value) { | |
| 29 | - return TypedArrayProto_toStringTag(value) === 'Uint16Array'; | ||
| 21 | + return TypedArrayPrototypeGetSymbolToStringTag(value) === 'Uint16Array'; | ||
| 30 | 22 | } | |
| 31 | 23 | ||
| 32 | 24 | function isUint32Array(value) { | |
| 33 | - return TypedArrayProto_toStringTag(value) === 'Uint32Array'; | ||
| 25 | + return TypedArrayPrototypeGetSymbolToStringTag(value) === 'Uint32Array'; | ||
| 34 | 26 | } | |
| 35 | 27 | ||
| 36 | 28 | function isInt8Array(value) { | |
| 37 | - return TypedArrayProto_toStringTag(value) === 'Int8Array'; | ||
| 29 | + return TypedArrayPrototypeGetSymbolToStringTag(value) === 'Int8Array'; | ||
| 38 | 30 | } | |
| 39 | 31 | ||
| 40 | 32 | function isInt16Array(value) { | |
| 41 | - return TypedArrayProto_toStringTag(value) === 'Int16Array'; | ||
| 33 | + return TypedArrayPrototypeGetSymbolToStringTag(value) === 'Int16Array'; | ||
| 42 | 34 | } | |
| 43 | 35 | ||
| 44 | 36 | function isInt32Array(value) { | |
| 45 | - return TypedArrayProto_toStringTag(value) === 'Int32Array'; | ||
| 37 | + return TypedArrayPrototypeGetSymbolToStringTag(value) === 'Int32Array'; | ||
| 46 | 38 | } | |
| 47 | 39 | ||
| 48 | 40 | function isFloat32Array(value) { | |
| 49 | - return TypedArrayProto_toStringTag(value) === 'Float32Array'; | ||
| 41 | + return TypedArrayPrototypeGetSymbolToStringTag(value) === 'Float32Array'; | ||
| 50 | 42 | } | |
| 51 | 43 | ||
| 52 | 44 | function isFloat64Array(value) { | |
| 53 | - return TypedArrayProto_toStringTag(value) === 'Float64Array'; | ||
| 45 | + return TypedArrayPrototypeGetSymbolToStringTag(value) === 'Float64Array'; | ||
| 54 | 46 | } | |
| 55 | 47 | ||
| 56 | 48 | function isBigInt64Array(value) { | |
| 57 | - return TypedArrayProto_toStringTag(value) === 'BigInt64Array'; | ||
| 49 | + return TypedArrayPrototypeGetSymbolToStringTag(value) === 'BigInt64Array'; | ||
| 58 | 50 | } | |
| 59 | 51 | ||
| 60 | 52 | function isBigUint64Array(value) { | |
| 61 | - return TypedArrayProto_toStringTag(value) === 'BigUint64Array'; | ||
| 53 | + return TypedArrayPrototypeGetSymbolToStringTag(value) === 'BigUint64Array'; | ||
| 62 | 54 | } | |
| 63 | 55 | ||
| 64 | 56 | module.exports = { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments