Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f727998

Browse files
targosMylesBorins
authored andcommittedNov 3, 2020
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 ca66837 commit f727998

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
@@ -47,6 +49,12 @@ rules:
4749
message: "Use `const { Symbol } = primordials;` instead of the global."
4850
- name: Uint16Array
4951
message: "Use `const { Uint16Array } = primordials;` instead of the global."
52+
- name: Uint32Array
53+
message: "Use `const { Uint32Array } = primordials;` instead of the global."
54+
- name: Uint8Array
55+
message: "Use `const { Uint8Array } = primordials;` instead of the global."
56+
- name: Uint8ClampedArray
57+
message: "Use `const { Uint8ClampedArray } = primordials;` instead of the global."
5058
- name: WeakMap
5159
message: "Use `const { WeakMap } = primordials;` instead of the global."
5260
- 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

@@ -400,7 +401,7 @@ function SlowBuffer(length) {
400401
return createUnsafeBuffer(length);
401402
}
402403

403-
ObjectSetPrototypeOf(SlowBuffer.prototype, Uint8Array.prototype);
404+
ObjectSetPrototypeOf(SlowBuffer.prototype, Uint8ArrayPrototype);
404405
ObjectSetPrototypeOf(SlowBuffer, Uint8Array);
405406

406407
function allocate(size) {

‎lib/internal/buffer.js

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

1011
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
@@ -17,6 +17,7 @@ const {
1717
SetPrototype,
1818
SetPrototypeHas,
1919
StringPrototypeReplace,
20+
Uint32Array,
2021
} = primordials;
2122

2223
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
@@ -52,6 +52,10 @@ const {
5252
SymbolIterator,
5353
SymbolToStringTag,
5454
Uint16Array,
55+
Uint32Array,
56+
Uint8Array,
57+
Uint8ArrayPrototype,
58+
Uint8ClampedArray,
5559
uncurryThis,
5660
} = primordials;
5761

@@ -132,7 +136,7 @@ const mapSizeGetter = uncurryThis(
132136
ObjectGetOwnPropertyDescriptor(MapPrototype, 'size').get);
133137
const typedArraySizeGetter = uncurryThis(
134138
ObjectGetOwnPropertyDescriptor(
135-
ObjectGetPrototypeOf(Uint8Array.prototype), 'length').get);
139+
ObjectGetPrototypeOf(Uint8ArrayPrototype), 'length').get);
136140

137141
let hexSlice;
138142

‎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
@@ -11,6 +11,7 @@ const {
1111
PromiseResolve,
1212
Symbol,
1313
SymbolFor,
14+
Uint32Array,
1415
} = primordials;
1516

1617
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)
Please sign in to comment.