summaryrefslogtreecommitdiff
path: root/lib/internal/streams
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2019-11-22 18:04:46 +0100
committerMichaël Zasso <targos@protonmail.com>2019-11-25 10:28:15 +0100
commit0646eda4fc0affb98e13c30acb522e63b7fd6dde (patch)
tree078209f50b044e24ea2c72cbbe7dca6e34bb7e25 /lib/internal/streams
parent35c6e0cc2b56a5380e6808ef5603ecc2b167e032 (diff)
downloadandroid-node-v8-0646eda4fc0affb98e13c30acb522e63b7fd6dde.tar.gz
android-node-v8-0646eda4fc0affb98e13c30acb522e63b7fd6dde.tar.bz2
android-node-v8-0646eda4fc0affb98e13c30acb522e63b7fd6dde.zip
lib: flatten access to primordials
Store all primordials as properties of the primordials object. Static functions are prefixed by the constructor's name and prototype methods are prefixed by the constructor's name followed by "Prototype". For example: primordials.Object.keys becomes primordials.ObjectKeys. PR-URL: https://github.com/nodejs/node/pull/30610 Refs: https://github.com/nodejs/node/issues/29766 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Diffstat (limited to 'lib/internal/streams')
-rw-r--r--lib/internal/streams/async_iterator.js14
-rw-r--r--lib/internal/streams/lazy_transform.js14
-rw-r--r--lib/internal/streams/legacy.js8
-rw-r--r--lib/internal/streams/state.js6
4 files changed, 27 insertions, 15 deletions
diff --git a/lib/internal/streams/async_iterator.js b/lib/internal/streams/async_iterator.js
index 07f2191e71..e05813e5df 100644
--- a/lib/internal/streams/async_iterator.js
+++ b/lib/internal/streams/async_iterator.js
@@ -1,6 +1,10 @@
'use strict';
-const { Object } = primordials;
+const {
+ ObjectCreate,
+ ObjectGetPrototypeOf,
+ ObjectSetPrototypeOf,
+} = primordials;
const finished = require('internal/streams/end-of-stream');
@@ -49,10 +53,10 @@ function wrapForNext(lastPromise, iter) {
};
}
-const AsyncIteratorPrototype = Object.getPrototypeOf(
- Object.getPrototypeOf(async function* () {}).prototype);
+const AsyncIteratorPrototype = ObjectGetPrototypeOf(
+ ObjectGetPrototypeOf(async function* () {}).prototype);
-const ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf({
+const ReadableStreamAsyncIteratorPrototype = ObjectSetPrototypeOf({
get stream() {
return this[kStream];
},
@@ -135,7 +139,7 @@ const ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf({
}, AsyncIteratorPrototype);
const createReadableStreamAsyncIterator = (stream) => {
- const iterator = Object.create(ReadableStreamAsyncIteratorPrototype, {
+ const iterator = ObjectCreate(ReadableStreamAsyncIteratorPrototype, {
[kStream]: { value: stream, writable: true },
[kLastResolve]: { value: null, writable: true },
[kLastReject]: { value: null, writable: true },
diff --git a/lib/internal/streams/lazy_transform.js b/lib/internal/streams/lazy_transform.js
index 0036bf306c..6584159095 100644
--- a/lib/internal/streams/lazy_transform.js
+++ b/lib/internal/streams/lazy_transform.js
@@ -3,7 +3,11 @@
// for the stream, one conventional and one non-conventional.
'use strict';
-const { Object } = primordials;
+const {
+ ObjectDefineProperties,
+ ObjectDefineProperty,
+ ObjectSetPrototypeOf,
+} = primordials;
const stream = require('stream');
@@ -18,8 +22,8 @@ function LazyTransform(options) {
this.writable = true;
this.readable = true;
}
-Object.setPrototypeOf(LazyTransform.prototype, stream.Transform.prototype);
-Object.setPrototypeOf(LazyTransform, stream.Transform);
+ObjectSetPrototypeOf(LazyTransform.prototype, stream.Transform.prototype);
+ObjectSetPrototypeOf(LazyTransform, stream.Transform);
function makeGetter(name) {
return function() {
@@ -36,7 +40,7 @@ function makeGetter(name) {
function makeSetter(name) {
return function(val) {
- Object.defineProperty(this, name, {
+ ObjectDefineProperty(this, name, {
value: val,
enumerable: true,
configurable: true,
@@ -45,7 +49,7 @@ function makeSetter(name) {
};
}
-Object.defineProperties(LazyTransform.prototype, {
+ObjectDefineProperties(LazyTransform.prototype, {
_readableState: {
get: makeGetter('_readableState'),
set: makeSetter('_readableState'),
diff --git a/lib/internal/streams/legacy.js b/lib/internal/streams/legacy.js
index 062eabec38..702e3c56ba 100644
--- a/lib/internal/streams/legacy.js
+++ b/lib/internal/streams/legacy.js
@@ -1,14 +1,16 @@
'use strict';
-const { Object } = primordials;
+const {
+ ObjectSetPrototypeOf,
+} = primordials;
const EE = require('events');
function Stream() {
EE.call(this);
}
-Object.setPrototypeOf(Stream.prototype, EE.prototype);
-Object.setPrototypeOf(Stream, EE);
+ObjectSetPrototypeOf(Stream.prototype, EE.prototype);
+ObjectSetPrototypeOf(Stream, EE);
Stream.prototype.pipe = function(dest, options) {
const source = this;
diff --git a/lib/internal/streams/state.js b/lib/internal/streams/state.js
index a3f5e67286..aa16a0a6b8 100644
--- a/lib/internal/streams/state.js
+++ b/lib/internal/streams/state.js
@@ -1,6 +1,8 @@
'use strict';
-const { Math } = primordials;
+const {
+ MathFloor,
+} = primordials;
const { ERR_INVALID_OPT_VALUE } = require('internal/errors').codes;
@@ -20,7 +22,7 @@ function getHighWaterMark(state, options, duplexKey, isDuplex) {
const name = isDuplex ? duplexKey : 'highWaterMark';
throw new ERR_INVALID_OPT_VALUE(name, hwm);
}
- return Math.floor(hwm);
+ return MathFloor(hwm);
}
// Default value