summaryrefslogtreecommitdiff
path: root/lib/_stream_duplex.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_duplex.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_duplex.js')
-rw-r--r--lib/_stream_duplex.js26
1 files changed, 15 insertions, 11 deletions
diff --git a/lib/_stream_duplex.js b/lib/_stream_duplex.js
index 858dc938f0..572e6da94d 100644
--- a/lib/_stream_duplex.js
+++ b/lib/_stream_duplex.js
@@ -26,19 +26,23 @@
'use strict';
-const { Object } = primordials;
+const {
+ ObjectDefineProperty,
+ ObjectKeys,
+ ObjectSetPrototypeOf,
+} = primordials;
module.exports = Duplex;
const Readable = require('_stream_readable');
const Writable = require('_stream_writable');
-Object.setPrototypeOf(Duplex.prototype, Readable.prototype);
-Object.setPrototypeOf(Duplex, Readable);
+ObjectSetPrototypeOf(Duplex.prototype, Readable.prototype);
+ObjectSetPrototypeOf(Duplex, Readable);
{
// Allow the keys array to be GC'ed.
- const keys = Object.keys(Writable.prototype);
+ const keys = ObjectKeys(Writable.prototype);
for (let v = 0; v < keys.length; v++) {
const method = keys[v];
if (!Duplex.prototype[method])
@@ -68,7 +72,7 @@ function Duplex(options) {
}
}
-Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
+ObjectDefineProperty(Duplex.prototype, 'writableHighWaterMark', {
// Making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
@@ -78,7 +82,7 @@ Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
}
});
-Object.defineProperty(Duplex.prototype, 'writableBuffer', {
+ObjectDefineProperty(Duplex.prototype, 'writableBuffer', {
// Making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
@@ -88,7 +92,7 @@ Object.defineProperty(Duplex.prototype, 'writableBuffer', {
}
});
-Object.defineProperty(Duplex.prototype, 'writableLength', {
+ObjectDefineProperty(Duplex.prototype, 'writableLength', {
// Making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
@@ -98,7 +102,7 @@ Object.defineProperty(Duplex.prototype, 'writableLength', {
}
});
-Object.defineProperty(Duplex.prototype, 'writableFinished', {
+ObjectDefineProperty(Duplex.prototype, 'writableFinished', {
// Making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
@@ -108,7 +112,7 @@ Object.defineProperty(Duplex.prototype, 'writableFinished', {
}
});
-Object.defineProperty(Duplex.prototype, 'writableCorked', {
+ObjectDefineProperty(Duplex.prototype, 'writableCorked', {
// Making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
@@ -118,7 +122,7 @@ Object.defineProperty(Duplex.prototype, 'writableCorked', {
}
});
-Object.defineProperty(Duplex.prototype, 'writableEnded', {
+ObjectDefineProperty(Duplex.prototype, 'writableEnded', {
// Making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
@@ -143,7 +147,7 @@ function onEndNT(self) {
self.end();
}
-Object.defineProperty(Duplex.prototype, 'destroyed', {
+ObjectDefineProperty(Duplex.prototype, 'destroyed', {
// Making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail