Skip to content

Commit fa171db

Browse files
targosBethGriggs
authored andcommitted
lib: use remaining typed arrays from primordials
PR-URL: #35499 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Ujjwal Sharma <[email protected]> Reviewed-By: Shingo Inoue <[email protected]>
1 parent 7e8fdd3 commit fa171db

13 files changed

+29
-3
lines changed

lib/.eslintrc.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ rules:
1111
- error
1212
- name: Array
1313
message: "Use `const { Array } = primordials;` instead of the global."
14+
- name: ArrayBuffer
15+
message: "Use `const { ArrayBuffer } = primordials;` instead of the global."
1416
- name: BigInt
1517
message: "Use `const { BigInt } = primordials;` instead of the global."
1618
- name: BigInt64Array
@@ -67,6 +69,12 @@ rules:
6769
message: "Use `const { URIError } = primordials;` instead of the global."
6870
- name: Uint16Array
6971
message: "Use `const { Uint16Array } = primordials;` instead of the global."
72+
- name: Uint32Array
73+
message: "Use `const { Uint32Array } = primordials;` instead of the global."
74+
- name: Uint8Array
75+
message: "Use `const { Uint8Array } = primordials;` instead of the global."
76+
- name: Uint8ClampedArray
77+
message: "Use `const { Uint8ClampedArray } = primordials;` instead of the global."
7078
- name: WeakMap
7179
message: "Use `const { WeakMap } = primordials;` instead of the global."
7280
- name: WeakSet

lib/buffer.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const {
3939
ObjectSetPrototypeOf,
4040
SymbolSpecies,
4141
SymbolToPrimitive,
42+
Uint8Array,
4243
Uint8ArrayPrototype,
4344
} = primordials;
4445

@@ -403,7 +404,7 @@ function SlowBuffer(length) {
403404
return createUnsafeBuffer(length);
404405
}
405406

406-
ObjectSetPrototypeOf(SlowBuffer.prototype, Uint8Array.prototype);
407+
ObjectSetPrototypeOf(SlowBuffer.prototype, Uint8ArrayPrototype);
407408
ObjectSetPrototypeOf(SlowBuffer, Uint8Array);
408409

409410
function allocate(size) {

lib/internal/buffer.js

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const {
66
Float64Array,
77
MathFloor,
88
Number,
9+
Uint8Array,
910
} = primordials;
1011

1112
const {

lib/internal/child_process.js

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const {
55
ObjectDefineProperty,
66
ObjectSetPrototypeOf,
77
Symbol,
8+
Uint8Array,
89
} = primordials;
910

1011
const {

lib/internal/encoding.js

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ const {
1010
ObjectGetOwnPropertyDescriptors,
1111
Symbol,
1212
SymbolToStringTag,
13+
Uint32Array,
14+
Uint8Array,
1315
} = primordials;
1416

1517
const {

lib/internal/http2/core.js

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ const {
1515
ReflectGetPrototypeOf,
1616
Set,
1717
Symbol,
18+
Uint32Array,
19+
Uint8Array,
1820
} = primordials;
1921

2022
const {

lib/internal/process/per_thread.js

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const {
1818
SetPrototype,
1919
SetPrototypeHas,
2020
StringPrototypeReplace,
21+
Uint32Array,
2122
} = primordials;
2223

2324
const {

lib/internal/streams/buffer_list.js

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const {
44
SymbolIterator,
5+
Uint8Array,
56
} = primordials;
67

78
const { Buffer } = require('buffer');

lib/internal/util/comparisons.js

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const {
2020
StringPrototypeValueOf,
2121
SymbolPrototypeValueOf,
2222
SymbolToStringTag,
23+
Uint8Array,
2324
} = primordials;
2425

2526
const { compare } = internalBinding('buffer');

lib/internal/util/inspect.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ const {
5858
SymbolIterator,
5959
SymbolToStringTag,
6060
Uint16Array,
61+
Uint32Array,
62+
Uint8Array,
63+
Uint8ArrayPrototype,
64+
Uint8ClampedArray,
6165
uncurryThis,
6266
} = primordials;
6367

@@ -138,7 +142,7 @@ const mapSizeGetter = uncurryThis(
138142
ObjectGetOwnPropertyDescriptor(MapPrototype, 'size').get);
139143
const typedArraySizeGetter = uncurryThis(
140144
ObjectGetOwnPropertyDescriptor(
141-
ObjectGetPrototypeOf(Uint8Array.prototype), 'length').get);
145+
ObjectGetPrototypeOf(Uint8ArrayPrototype), 'length').get);
142146

143147
let hexSlice;
144148

lib/internal/util/types.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ const {
55
ObjectGetOwnPropertyDescriptor,
66
ObjectGetPrototypeOf,
77
SymbolToStringTag,
8+
Uint8ArrayPrototype,
89
uncurryThis,
910
} = primordials;
1011

11-
const TypedArrayPrototype = ObjectGetPrototypeOf(Uint8Array.prototype);
12+
const TypedArrayPrototype = ObjectGetPrototypeOf(Uint8ArrayPrototype);
1213

1314
const TypedArrayProto_toStringTag =
1415
uncurryThis(

lib/internal/worker.js

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const {
1414
String,
1515
Symbol,
1616
SymbolFor,
17+
Uint32Array,
1718
} = primordials;
1819

1920
const EventEmitter = require('events');

lib/zlib.js

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
'use strict';
2323

2424
const {
25+
ArrayBuffer,
2526
Error,
2627
MathMax,
2728
NumberIsFinite,
@@ -33,6 +34,7 @@ const {
3334
ObjectKeys,
3435
ObjectSetPrototypeOf,
3536
Symbol,
37+
Uint32Array,
3638
} = primordials;
3739

3840
const {

0 commit comments

Comments
 (0)