Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit af2a560

Browse filesBrowse files
ExE-Bossdanielleadams
authored andcommitted
lib: add %TypedArray% abstract constructor to primordials
Refs: #35448 Refs: #36003 Refs: https://tc39.es/ecma262/#sec-%typedarray%-intrinsic-object Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com> PR-URL: #36016 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
1 parent 77e4f19 commit af2a560
Copy full SHA for af2a560

File tree

Expand file treeCollapse file tree

4 files changed

+20
-9
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+20
-9
lines changed
Open diff view settings
Collapse file

‎lib/internal/freeze_intrinsics.js‎

Copy file name to clipboardExpand all lines: lib/internal/freeze_intrinsics.js
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ const {
6565
SymbolIterator,
6666
SyntaxError,
6767
TypeError,
68+
TypedArray,
69+
TypedArrayPrototype,
6870
Uint16Array,
6971
Uint32Array,
7072
Uint8Array,
@@ -105,7 +107,7 @@ module.exports = function() {
105107
// AsyncGeneratorFunction
106108
ObjectGetPrototypeOf(async function* () {}),
107109
// TypedArray
108-
ObjectGetPrototypeOf(Uint8Array),
110+
TypedArrayPrototype,
109111

110112
// 19 Fundamental Objects
111113
Object.prototype, // 19.1
@@ -189,7 +191,7 @@ module.exports = function() {
189191
// AsyncGeneratorFunction
190192
ObjectGetPrototypeOf(async function* () {}),
191193
// TypedArray
192-
ObjectGetPrototypeOf(Uint8Array),
194+
TypedArray,
193195

194196
// 18 The Global Object
195197
eval,
Collapse file

‎lib/internal/per_context/primordials.js‎

Copy file name to clipboardExpand all lines: lib/internal/per_context/primordials.js
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,5 +175,18 @@ primordials.SafePromise = makeSafe(
175175
copyPrototype(original.prototype, primordials, `${name}Prototype`);
176176
});
177177

178+
// Create copies of abstract intrinsic objects that are not directly exposed
179+
// on the global object.
180+
// Refs: https://tc39.es/ecma262/#sec-%typedarray%-intrinsic-object
181+
[
182+
{ name: 'TypedArray', original: Reflect.getPrototypeOf(Uint8Array) },
183+
].forEach(({ name, original }) => {
184+
primordials[name] = original;
185+
// The static %TypedArray% methods require a valid `this`, but can't be bound,
186+
// as they need a subclass constructor as the receiver:
187+
copyPrototype(original, primordials, name);
188+
copyPrototype(original.prototype, primordials, `${name}Prototype`);
189+
});
190+
178191
Object.setPrototypeOf(primordials, null);
179192
Object.freeze(primordials);
Collapse file

‎lib/internal/util/inspect.js‎

Copy file name to clipboardExpand all lines: lib/internal/util/inspect.js
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ const {
5757
SymbolPrototypeValueOf,
5858
SymbolIterator,
5959
SymbolToStringTag,
60+
TypedArrayPrototype,
6061
Uint16Array,
6162
Uint32Array,
6263
Uint8Array,
63-
Uint8ArrayPrototype,
6464
Uint8ClampedArray,
6565
uncurryThis,
6666
} = primordials;
@@ -141,8 +141,7 @@ const setSizeGetter = uncurryThis(
141141
const mapSizeGetter = uncurryThis(
142142
ObjectGetOwnPropertyDescriptor(MapPrototype, 'size').get);
143143
const typedArraySizeGetter = uncurryThis(
144-
ObjectGetOwnPropertyDescriptor(
145-
ObjectGetPrototypeOf(Uint8ArrayPrototype), 'length').get);
144+
ObjectGetOwnPropertyDescriptor(TypedArrayPrototype, 'length').get);
146145

147146
let hexSlice;
148147

Collapse file

‎lib/internal/util/types.js‎

Copy file name to clipboardExpand all lines: lib/internal/util/types.js
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,11 @@
33
const {
44
ArrayBufferIsView,
55
ObjectGetOwnPropertyDescriptor,
6-
ObjectGetPrototypeOf,
76
SymbolToStringTag,
8-
Uint8ArrayPrototype,
7+
TypedArrayPrototype,
98
uncurryThis,
109
} = primordials;
1110

12-
const TypedArrayPrototype = ObjectGetPrototypeOf(Uint8ArrayPrototype);
13-
1411
const TypedArrayProto_toStringTag =
1512
uncurryThis(
1613
ObjectGetOwnPropertyDescriptor(TypedArrayPrototype,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.