summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichaƫl Zasso <targos@protonmail.com>2020-09-28 16:56:54 +0200
committerMyles Borins <mylesborins@github.com>2020-11-16 11:57:59 -0500
commitad7281b0817b47f428e8da2c22ea3fb42ca13c87 (patch)
tree26c1abec4e173f9bfd1e760eff85399d041c912f
parent7f8834f76c510a5eeab4157841959d3915d2fc83 (diff)
downloadnode-new-ad7281b0817b47f428e8da2c22ea3fb42ca13c87.tar.gz
lib: use remaining typed arrays from primordials
PR-URL: https://github.com/nodejs/node/pull/35499 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org> Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
-rw-r--r--lib/.eslintrc.yaml8
-rw-r--r--lib/buffer.js3
-rw-r--r--lib/internal/buffer.js1
-rw-r--r--lib/internal/child_process.js1
-rw-r--r--lib/internal/encoding.js2
-rw-r--r--lib/internal/http2/core.js2
-rw-r--r--lib/internal/process/per_thread.js1
-rw-r--r--lib/internal/streams/buffer_list.js1
-rw-r--r--lib/internal/util/comparisons.js1
-rw-r--r--lib/internal/util/inspect.js6
-rw-r--r--lib/internal/util/types.js3
-rw-r--r--lib/internal/worker.js1
-rw-r--r--lib/zlib.js2
13 files changed, 29 insertions, 3 deletions
diff --git a/lib/.eslintrc.yaml b/lib/.eslintrc.yaml
index 97cc264c8f..39caa3dee9 100644
--- a/lib/.eslintrc.yaml
+++ b/lib/.eslintrc.yaml
@@ -11,6 +11,8 @@ rules:
- error
- name: Array
message: "Use `const { Array } = primordials;` instead of the global."
+ - name: ArrayBuffer
+ message: "Use `const { ArrayBuffer } = primordials;` instead of the global."
- name: BigInt
message: "Use `const { BigInt } = primordials;` instead of the global."
- name: BigInt64Array
@@ -47,6 +49,12 @@ rules:
message: "Use `const { Symbol } = primordials;` instead of the global."
- name: Uint16Array
message: "Use `const { Uint16Array } = primordials;` instead of the global."
+ - name: Uint32Array
+ message: "Use `const { Uint32Array } = primordials;` instead of the global."
+ - name: Uint8Array
+ message: "Use `const { Uint8Array } = primordials;` instead of the global."
+ - name: Uint8ClampedArray
+ message: "Use `const { Uint8ClampedArray } = primordials;` instead of the global."
- name: WeakMap
message: "Use `const { WeakMap } = primordials;` instead of the global."
- name: WeakSet
diff --git a/lib/buffer.js b/lib/buffer.js
index 90ebe8866b..201626e13a 100644
--- a/lib/buffer.js
+++ b/lib/buffer.js
@@ -39,6 +39,7 @@ const {
ObjectSetPrototypeOf,
SymbolSpecies,
SymbolToPrimitive,
+ Uint8Array,
Uint8ArrayPrototype,
} = primordials;
@@ -400,7 +401,7 @@ function SlowBuffer(length) {
return createUnsafeBuffer(length);
}
-ObjectSetPrototypeOf(SlowBuffer.prototype, Uint8Array.prototype);
+ObjectSetPrototypeOf(SlowBuffer.prototype, Uint8ArrayPrototype);
ObjectSetPrototypeOf(SlowBuffer, Uint8Array);
function allocate(size) {
diff --git a/lib/internal/buffer.js b/lib/internal/buffer.js
index 03f12d809d..b54ca4e767 100644
--- a/lib/internal/buffer.js
+++ b/lib/internal/buffer.js
@@ -5,6 +5,7 @@ const {
Float32Array,
MathFloor,
Number,
+ Uint8Array,
} = primordials;
const {
diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js
index 6570b599e3..15d3ef3bf0 100644
--- a/lib/internal/child_process.js
+++ b/lib/internal/child_process.js
@@ -5,6 +5,7 @@ const {
ObjectDefineProperty,
ObjectSetPrototypeOf,
Symbol,
+ Uint8Array,
} = primordials;
const {
diff --git a/lib/internal/encoding.js b/lib/internal/encoding.js
index befc4f811b..8562fb32ff 100644
--- a/lib/internal/encoding.js
+++ b/lib/internal/encoding.js
@@ -10,6 +10,8 @@ const {
ObjectGetOwnPropertyDescriptors,
Symbol,
SymbolToStringTag,
+ Uint32Array,
+ Uint8Array,
} = primordials;
const {
diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js
index 7e77ac61cc..078ce47853 100644
--- a/lib/internal/http2/core.js
+++ b/lib/internal/http2/core.js
@@ -15,6 +15,8 @@ const {
ReflectGetPrototypeOf,
Set,
Symbol,
+ Uint32Array,
+ Uint8Array,
} = primordials;
const {
diff --git a/lib/internal/process/per_thread.js b/lib/internal/process/per_thread.js
index d219cd7298..5d8e826d81 100644
--- a/lib/internal/process/per_thread.js
+++ b/lib/internal/process/per_thread.js
@@ -17,6 +17,7 @@ const {
SetPrototype,
SetPrototypeHas,
StringPrototypeReplace,
+ Uint32Array,
} = primordials;
const {
diff --git a/lib/internal/streams/buffer_list.js b/lib/internal/streams/buffer_list.js
index fc8dd1b1f0..2551bee447 100644
--- a/lib/internal/streams/buffer_list.js
+++ b/lib/internal/streams/buffer_list.js
@@ -2,6 +2,7 @@
const {
SymbolIterator,
+ Uint8Array,
} = primordials;
const { Buffer } = require('buffer');
diff --git a/lib/internal/util/comparisons.js b/lib/internal/util/comparisons.js
index c8e277abb7..66be3fe701 100644
--- a/lib/internal/util/comparisons.js
+++ b/lib/internal/util/comparisons.js
@@ -20,6 +20,7 @@ const {
StringPrototypeValueOf,
SymbolPrototypeValueOf,
SymbolToStringTag,
+ Uint8Array,
} = primordials;
const { compare } = internalBinding('buffer');
diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js
index e6bd5ee542..7d35301bb6 100644
--- a/lib/internal/util/inspect.js
+++ b/lib/internal/util/inspect.js
@@ -52,6 +52,10 @@ const {
SymbolIterator,
SymbolToStringTag,
Uint16Array,
+ Uint32Array,
+ Uint8Array,
+ Uint8ArrayPrototype,
+ Uint8ClampedArray,
uncurryThis,
} = primordials;
@@ -132,7 +136,7 @@ const mapSizeGetter = uncurryThis(
ObjectGetOwnPropertyDescriptor(MapPrototype, 'size').get);
const typedArraySizeGetter = uncurryThis(
ObjectGetOwnPropertyDescriptor(
- ObjectGetPrototypeOf(Uint8Array.prototype), 'length').get);
+ ObjectGetPrototypeOf(Uint8ArrayPrototype), 'length').get);
let hexSlice;
diff --git a/lib/internal/util/types.js b/lib/internal/util/types.js
index 676f386a24..4b9eeb469b 100644
--- a/lib/internal/util/types.js
+++ b/lib/internal/util/types.js
@@ -5,10 +5,11 @@ const {
ObjectGetOwnPropertyDescriptor,
ObjectGetPrototypeOf,
SymbolToStringTag,
+ Uint8ArrayPrototype,
uncurryThis,
} = primordials;
-const TypedArrayPrototype = ObjectGetPrototypeOf(Uint8Array.prototype);
+const TypedArrayPrototype = ObjectGetPrototypeOf(Uint8ArrayPrototype);
const TypedArrayProto_toStringTag =
uncurryThis(
diff --git a/lib/internal/worker.js b/lib/internal/worker.js
index b62cc9382f..e595749259 100644
--- a/lib/internal/worker.js
+++ b/lib/internal/worker.js
@@ -11,6 +11,7 @@ const {
PromiseResolve,
Symbol,
SymbolFor,
+ Uint32Array,
} = primordials;
const EventEmitter = require('events');
diff --git a/lib/zlib.js b/lib/zlib.js
index 7440280c1b..a3641d6c92 100644
--- a/lib/zlib.js
+++ b/lib/zlib.js
@@ -22,6 +22,7 @@
'use strict';
const {
+ ArrayBuffer,
Error,
MathMax,
NumberIsFinite,
@@ -33,6 +34,7 @@ const {
ObjectKeys,
ObjectSetPrototypeOf,
Symbol,
+ Uint32Array,
} = primordials;
const {