summaryrefslogtreecommitdiff
path: root/lib/_stream_readable.js
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/_stream_readable.js
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/_stream_readable.js')
-rw-r--r--lib/_stream_readable.js27
1 files changed, 15 insertions, 12 deletions
diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js
index 71fd74b07b..69f46f80a0 100644
--- a/lib/_stream_readable.js
+++ b/lib/_stream_readable.js
@@ -21,7 +21,10 @@
'use strict';
-const { Object } = primordials;
+const {
+ ObjectDefineProperty,
+ ObjectSetPrototypeOf,
+} = primordials;
module.exports = Readable;
Readable.ReadableState = ReadableState;
@@ -49,8 +52,8 @@ let StringDecoder;
let createReadableStreamAsyncIterator;
let from;
-Object.setPrototypeOf(Readable.prototype, Stream.prototype);
-Object.setPrototypeOf(Readable, Stream);
+ObjectSetPrototypeOf(Readable.prototype, Stream.prototype);
+ObjectSetPrototypeOf(Readable, Stream);
const { errorOrDestroy } = destroyImpl;
const kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
@@ -157,7 +160,7 @@ function ReadableState(options, stream, isDuplex) {
}
// Legacy getter for `pipesCount`
-Object.defineProperty(ReadableState.prototype, 'pipesCount', {
+ObjectDefineProperty(ReadableState.prototype, 'pipesCount', {
get() {
return this.pipes.length;
}
@@ -187,7 +190,7 @@ function Readable(options) {
Stream.call(this);
}
-Object.defineProperty(Readable.prototype, 'destroyed', {
+ObjectDefineProperty(Readable.prototype, 'destroyed', {
// Making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
@@ -211,7 +214,7 @@ Object.defineProperty(Readable.prototype, 'destroyed', {
}
});
-Object.defineProperty(Readable.prototype, 'readableEnded', {
+ObjectDefineProperty(Readable.prototype, 'readableEnded', {
// Making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
@@ -1089,7 +1092,7 @@ Readable.prototype[Symbol.asyncIterator] = function() {
return createReadableStreamAsyncIterator(this);
};
-Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
+ObjectDefineProperty(Readable.prototype, 'readableHighWaterMark', {
// Making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
@@ -1099,7 +1102,7 @@ Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
}
});
-Object.defineProperty(Readable.prototype, 'readableBuffer', {
+ObjectDefineProperty(Readable.prototype, 'readableBuffer', {
// Making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
@@ -1109,7 +1112,7 @@ Object.defineProperty(Readable.prototype, 'readableBuffer', {
}
});
-Object.defineProperty(Readable.prototype, 'readableFlowing', {
+ObjectDefineProperty(Readable.prototype, 'readableFlowing', {
// Making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
@@ -1127,7 +1130,7 @@ Object.defineProperty(Readable.prototype, 'readableFlowing', {
// Exposed for testing purposes only.
Readable._fromList = fromList;
-Object.defineProperty(Readable.prototype, 'readableLength', {
+ObjectDefineProperty(Readable.prototype, 'readableLength', {
// Making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
@@ -1137,14 +1140,14 @@ Object.defineProperty(Readable.prototype, 'readableLength', {
}
});
-Object.defineProperty(Readable.prototype, 'readableObjectMode', {
+ObjectDefineProperty(Readable.prototype, 'readableObjectMode', {
enumerable: false,
get() {
return this._readableState ? this._readableState.objectMode : false;
}
});
-Object.defineProperty(Readable.prototype, 'readableEncoding', {
+ObjectDefineProperty(Readable.prototype, 'readableEncoding', {
enumerable: false,
get() {
return this._readableState ? this._readableState.encoding : null;