mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
lib: add %TypedArray% abstract constructor to primordials
Refs: https://github.com/nodejs/node/pull/35448 Refs: https://github.com/nodejs/node/pull/36003 Refs: https://tc39.es/ecma262/#sec-%typedarray%-intrinsic-object Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com> PR-URL: https://github.com/nodejs/node/pull/36016 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
This commit is contained in:
1 parent
aa1eb1fd59
commit
c925e24ae7
4 files changed
+20
-9
No files matched your search
@@ -65,6 +65,8 @@ const {
|
||||
SymbolIterator,
|
||||
SyntaxError,
|
||||
TypeError,
|
||||
TypedArray,
|
||||
TypedArrayPrototype,
|
||||
Uint16Array,
|
||||
Uint32Array,
|
||||
Uint8Array,
|
||||
@@ -105,7 +107,7 @@ module.exports = function() {
|
||||
// AsyncGeneratorFunction
|
||||
ObjectGetPrototypeOf(async function* () {}),
|
||||
// TypedArray
|
||||
ObjectGetPrototypeOf(Uint8Array),
|
||||
TypedArrayPrototype,
|
||||
|
||||
// 19 Fundamental Objects
|
||||
Object.prototype, // 19.1
|
||||
@@ -189,7 +191,7 @@ module.exports = function() {
|
||||
// AsyncGeneratorFunction
|
||||
ObjectGetPrototypeOf(async function* () {}),
|
||||
// TypedArray
|
||||
ObjectGetPrototypeOf(Uint8Array),
|
||||
TypedArray,
|
||||
|
||||
// 18 The Global Object
|
||||
eval,
|
||||
|
||||
@@ -175,5 +175,18 @@ primordials.SafePromise = makeSafe(
|
||||
copyPrototype(original.prototype, primordials, `${name}Prototype`);
|
||||
});
|
||||
|
||||
// Create copies of abstract intrinsic objects that are not directly exposed
|
||||
// on the global object.
|
||||
// Refs: https://tc39.es/ecma262/#sec-%typedarray%-intrinsic-object
|
||||
[
|
||||
{ name: 'TypedArray', original: Reflect.getPrototypeOf(Uint8Array) },
|
||||
].forEach(({ name, original }) => {
|
||||
primordials[name] = original;
|
||||
// The static %TypedArray% methods require a valid `this`, but can't be bound,
|
||||
// as they need a subclass constructor as the receiver:
|
||||
copyPrototype(original, primordials, name);
|
||||
copyPrototype(original.prototype, primordials, `${name}Prototype`);
|
||||
});
|
||||
|
||||
Object.setPrototypeOf(primordials, null);
|
||||
Object.freeze(primordials);
|
||||
@@ -57,10 +57,10 @@ const {
|
||||
SymbolPrototypeValueOf,
|
||||
SymbolIterator,
|
||||
SymbolToStringTag,
|
||||
TypedArrayPrototype,
|
||||
Uint16Array,
|
||||
Uint32Array,
|
||||
Uint8Array,
|
||||
Uint8ArrayPrototype,
|
||||
Uint8ClampedArray,
|
||||
uncurryThis,
|
||||
} = primordials;
|
||||
@@ -141,8 +141,7 @@ const setSizeGetter = uncurryThis(
|
||||
const mapSizeGetter = uncurryThis(
|
||||
ObjectGetOwnPropertyDescriptor(MapPrototype, 'size').get);
|
||||
const typedArraySizeGetter = uncurryThis(
|
||||
ObjectGetOwnPropertyDescriptor(
|
||||
ObjectGetPrototypeOf(Uint8ArrayPrototype), 'length').get);
|
||||
ObjectGetOwnPropertyDescriptor(TypedArrayPrototype, 'length').get);
|
||||
|
||||
let hexSlice;
|
||||
|
||||
|
||||
@@ -3,14 +3,11 @@
|
||||
const {
|
||||
ArrayBufferIsView,
|
||||
ObjectGetOwnPropertyDescriptor,
|
||||
ObjectGetPrototypeOf,
|
||||
SymbolToStringTag,
|
||||
Uint8ArrayPrototype,
|
||||
TypedArrayPrototype,
|
||||
uncurryThis,
|
||||
} = primordials;
|
||||
|
||||
const TypedArrayPrototype = ObjectGetPrototypeOf(Uint8ArrayPrototype);
|
||||
|
||||
const TypedArrayProto_toStringTag =
|
||||
uncurryThis(
|
||||
ObjectGetOwnPropertyDescriptor(TypedArrayPrototype,
|
||||
|
||||
Reference in new issue
Block a user