diff options
author | Michaël Zasso <targos@protonmail.com> | 2019-11-22 18:04:46 +0100 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2019-11-25 10:28:15 +0100 |
commit | 0646eda4fc0affb98e13c30acb522e63b7fd6dde (patch) | |
tree | 078209f50b044e24ea2c72cbbe7dca6e34bb7e25 /lib/_stream_writable.js | |
parent | 35c6e0cc2b56a5380e6808ef5603ecc2b167e032 (diff) | |
download | android-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_writable.js')
-rw-r--r-- | lib/_stream_writable.js | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js index c7a3047dc7..5eb34dc213 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -25,7 +25,10 @@ 'use strict'; -const { Object } = primordials; +const { + ObjectDefineProperty, + ObjectSetPrototypeOf, +} = primordials; module.exports = Writable; Writable.WritableState = WritableState; @@ -52,8 +55,8 @@ const { const { errorOrDestroy } = destroyImpl; -Object.setPrototypeOf(Writable.prototype, Stream.prototype); -Object.setPrototypeOf(Writable, Stream); +ObjectSetPrototypeOf(Writable.prototype, Stream.prototype); +ObjectSetPrototypeOf(Writable, Stream); function nop() {} @@ -183,7 +186,7 @@ WritableState.prototype.getBuffer = function getBuffer() { return out; }; -Object.defineProperty(WritableState.prototype, 'buffer', { +ObjectDefineProperty(WritableState.prototype, 'buffer', { get: internalUtil.deprecate(function writableStateBufferGetter() { return this.getBuffer(); }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + @@ -195,7 +198,7 @@ Object.defineProperty(WritableState.prototype, 'buffer', { var realHasInstance; if (typeof Symbol === 'function' && Symbol.hasInstance) { realHasInstance = Function.prototype[Symbol.hasInstance]; - Object.defineProperty(Writable, Symbol.hasInstance, { + ObjectDefineProperty(Writable, Symbol.hasInstance, { value: function(object) { if (realHasInstance.call(this, object)) return true; @@ -346,7 +349,7 @@ Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { return this; }; -Object.defineProperty(Writable.prototype, 'writableBuffer', { +ObjectDefineProperty(Writable.prototype, 'writableBuffer', { // Making it explicit this property is not enumerable // because otherwise some prototype manipulation in // userland will fail @@ -365,7 +368,7 @@ function decodeChunk(state, chunk, encoding) { return chunk; } -Object.defineProperty(Writable.prototype, 'writableEnded', { +ObjectDefineProperty(Writable.prototype, 'writableEnded', { // Making it explicit this property is not enumerable // because otherwise some prototype manipulation in // userland will fail @@ -375,7 +378,7 @@ Object.defineProperty(Writable.prototype, 'writableEnded', { } }); -Object.defineProperty(Writable.prototype, 'writableHighWaterMark', { +ObjectDefineProperty(Writable.prototype, 'writableHighWaterMark', { // Making it explicit this property is not enumerable // because otherwise some prototype manipulation in // userland will fail @@ -385,7 +388,7 @@ Object.defineProperty(Writable.prototype, 'writableHighWaterMark', { } }); -Object.defineProperty(Writable.prototype, 'writableCorked', { +ObjectDefineProperty(Writable.prototype, 'writableCorked', { // Making it explicit this property is not enumerable // because otherwise some prototype manipulation in // userland will fail @@ -624,7 +627,7 @@ Writable.prototype.end = function(chunk, encoding, cb) { return this; }; -Object.defineProperty(Writable.prototype, 'writableLength', { +ObjectDefineProperty(Writable.prototype, 'writableLength', { // Making it explicit this property is not enumerable // because otherwise some prototype manipulation in // userland will fail @@ -741,7 +744,7 @@ function onFinished(stream, state, cb) { stream.prependListener('error', onerror); } -Object.defineProperty(Writable.prototype, 'destroyed', { +ObjectDefineProperty(Writable.prototype, 'destroyed', { // Making it explicit this property is not enumerable // because otherwise some prototype manipulation in // userland will fail @@ -765,14 +768,14 @@ Object.defineProperty(Writable.prototype, 'destroyed', { } }); -Object.defineProperty(Writable.prototype, 'writableObjectMode', { +ObjectDefineProperty(Writable.prototype, 'writableObjectMode', { enumerable: false, get() { return this._writableState ? this._writableState.objectMode : false; } }); -Object.defineProperty(Writable.prototype, 'writableFinished', { +ObjectDefineProperty(Writable.prototype, 'writableFinished', { // Making it explicit this property is not enumerable // because otherwise some prototype manipulation in // userland will fail |