From 3a648af0f0e5315086c6b5d2bfa90c3804656ca0 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sat, 18 Feb 2023 18:53:57 +0100 Subject: [PATCH] stream: add trailing commas in stream source files PR-URL: https://github.com/nodejs/node/pull/46686 Reviewed-By: Robert Nagy Reviewed-By: Moshe Atlow Reviewed-By: Matteo Collina Reviewed-By: Darshan Sen --- lib/.eslintrc.yaml | 1 + lib/internal/streams/buffer_list.js | 2 +- lib/internal/streams/destroy.js | 4 +-- lib/internal/streams/duplex.js | 4 +-- lib/internal/streams/duplexify.js | 12 ++++---- lib/internal/streams/end-of-stream.js | 4 +-- lib/internal/streams/from.js | 4 +-- lib/internal/streams/lazy_transform.js | 10 +++--- lib/internal/streams/pipeline.js | 6 ++-- lib/internal/streams/readable.js | 42 +++++++++++++------------- lib/internal/streams/state.js | 2 +- lib/internal/streams/transform.js | 4 +-- lib/internal/streams/writable.js | 32 ++++++++++---------- 13 files changed, 64 insertions(+), 63 deletions(-) diff --git a/lib/.eslintrc.yaml b/lib/.eslintrc.yaml index 46a9a8500059c9..53942a3f30cb4a 100644 --- a/lib/.eslintrc.yaml +++ b/lib/.eslintrc.yaml @@ -290,6 +290,7 @@ overrides: - ./internal/readme.md - ./internal/repl/history.js - ./internal/source_map/prepare_stack_trace.js + - ./internal/streams/*.js - ./internal/structured_clone.js - ./internal/test/*.js - ./internal/test_runner/**/*.js diff --git a/lib/internal/streams/buffer_list.js b/lib/internal/streams/buffer_list.js index 5279f65b4bdd23..4629bdbf165e4f 100644 --- a/lib/internal/streams/buffer_list.js +++ b/lib/internal/streams/buffer_list.js @@ -175,7 +175,7 @@ module.exports = class BufferList { // Only inspect one level. depth: 0, // It should not recurse. - customInspect: false + customInspect: false, }); } }; diff --git a/lib/internal/streams/destroy.js b/lib/internal/streams/destroy.js index 09cc5590fad4fc..76433594662d91 100644 --- a/lib/internal/streams/destroy.js +++ b/lib/internal/streams/destroy.js @@ -14,7 +14,7 @@ const { kDestroyed, isDestroyed, isFinished, - isServerRequest + isServerRequest, } = require('internal/streams/utils'); const kDestroy = Symbol('kDestroy'); @@ -334,5 +334,5 @@ module.exports = { destroyer, destroy, undestroy, - errorOrDestroy + errorOrDestroy, }; diff --git a/lib/internal/streams/duplex.js b/lib/internal/streams/duplex.js index 4b9ca227ed5aa9..799eb5a32022da 100644 --- a/lib/internal/streams/duplex.js +++ b/lib/internal/streams/duplex.js @@ -114,8 +114,8 @@ ObjectDefineProperties(Duplex.prototype, { this._readableState.destroyed = value; this._writableState.destroyed = value; } - } - } + }, + }, }); let webStreamsAdapters; diff --git a/lib/internal/streams/duplexify.js b/lib/internal/streams/duplexify.js index f1395e9727e36b..788bcb63242c38 100644 --- a/lib/internal/streams/duplexify.js +++ b/lib/internal/streams/duplexify.js @@ -32,7 +32,7 @@ const { const { AbortController } = require('internal/abort_controller'); const { - FunctionPrototypeCall + FunctionPrototypeCall, } = primordials; // This is needed for pre node 17. @@ -91,7 +91,7 @@ module.exports = function duplexify(body, name) { objectMode: true, write, final, - destroy + destroy, }); } @@ -127,7 +127,7 @@ module.exports = function duplexify(body, name) { } }); }, - destroy + destroy, }); } @@ -143,7 +143,7 @@ module.exports = function duplexify(body, name) { return from(Duplexify, body, { // TODO (ronag): highWaterMark? objectMode: true, - writable: false + writable: false, }); } @@ -192,7 +192,7 @@ module.exports = function duplexify(body, name) { return d = new Duplexify({ objectMode: true, writable: false, - read() {} + read() {}, }); } @@ -236,7 +236,7 @@ function fromAsyncGen(fn) { destroy(err, cb) { ac.abort(); cb(err); - } + }, }; } diff --git a/lib/internal/streams/end-of-stream.js b/lib/internal/streams/end-of-stream.js index e0620dcd457780..df8fdeb50110d7 100644 --- a/lib/internal/streams/end-of-stream.js +++ b/lib/internal/streams/end-of-stream.js @@ -9,7 +9,7 @@ const { } = require('internal/errors'); const { ERR_INVALID_ARG_TYPE, - ERR_STREAM_PREMATURE_CLOSE + ERR_STREAM_PREMATURE_CLOSE, } = codes; const { kEmptyObject, @@ -19,7 +19,7 @@ const { validateAbortSignal, validateFunction, validateObject, - validateBoolean + validateBoolean, } = require('internal/validators'); const { Promise, PromisePrototypeThen } = primordials; diff --git a/lib/internal/streams/from.js b/lib/internal/streams/from.js index d3d43f7dfbb8ec..c272a01f418dce 100644 --- a/lib/internal/streams/from.js +++ b/lib/internal/streams/from.js @@ -9,7 +9,7 @@ const { Buffer } = require('buffer'); const { ERR_INVALID_ARG_TYPE, - ERR_STREAM_NULL_VALUES + ERR_STREAM_NULL_VALUES, } = require('internal/errors').codes; function from(Readable, iterable, opts) { @@ -21,7 +21,7 @@ function from(Readable, iterable, opts) { read() { this.push(iterable); this.push(null); - } + }, }); } diff --git a/lib/internal/streams/lazy_transform.js b/lib/internal/streams/lazy_transform.js index fc3e9815a37648..d9d1407a819594 100644 --- a/lib/internal/streams/lazy_transform.js +++ b/lib/internal/streams/lazy_transform.js @@ -12,7 +12,7 @@ const { const stream = require('stream'); const { - getDefaultEncoding + getDefaultEncoding, } = require('internal/crypto/util'); module.exports = LazyTransform; @@ -43,7 +43,7 @@ function makeSetter(name) { value: val, enumerable: true, configurable: true, - writable: true + writable: true, }); }; } @@ -54,13 +54,13 @@ ObjectDefineProperties(LazyTransform.prototype, { get: makeGetter('_readableState'), set: makeSetter('_readableState'), configurable: true, - enumerable: true + enumerable: true, }, _writableState: { __proto__: null, get: makeGetter('_writableState'), set: makeSetter('_writableState'), configurable: true, - enumerable: true - } + enumerable: true, + }, }); diff --git a/lib/internal/streams/pipeline.js b/lib/internal/streams/pipeline.js index 44c0e06ee30557..667b5268477d42 100644 --- a/lib/internal/streams/pipeline.js +++ b/lib/internal/streams/pipeline.js @@ -27,7 +27,7 @@ const { const { validateFunction, - validateAbortSignal + validateAbortSignal, } = require('internal/validators'); const { @@ -60,7 +60,7 @@ function destroyer(stream, reading, writing) { finished = true; destroyImpl.destroyer(stream, err || new ERR_STREAM_DESTROYED('pipe')); }, - cleanup + cleanup, }; } @@ -314,7 +314,7 @@ function pipelineImpl(streams, callback, opts) { // composed through `.pipe(stream)`. const pt = new PassThrough({ - objectMode: true + objectMode: true, }); // Handle Promises/A+ spec, `then` could be a getter that throws on diff --git a/lib/internal/streams/readable.js b/lib/internal/streams/readable.js index 4612c66cd0f427..7a2aad41ee2baa 100644 --- a/lib/internal/streams/readable.js +++ b/lib/internal/streams/readable.js @@ -32,7 +32,7 @@ const { Promise, SafeSet, SymbolAsyncIterator, - Symbol + Symbol, } = primordials; module.exports = Readable; @@ -54,7 +54,7 @@ const BufferList = require('internal/streams/buffer_list'); const destroyImpl = require('internal/streams/destroy'); const { getHighWaterMark, - getDefaultHighWaterMark + getDefaultHighWaterMark, } = require('internal/streams/state'); const { @@ -65,8 +65,8 @@ const { ERR_OUT_OF_RANGE, ERR_STREAM_PUSH_AFTER_EOF, ERR_STREAM_UNSHIFT_AFTER_END_EVENT, - ERR_UNKNOWN_ENCODING - } + ERR_UNKNOWN_ENCODING, + }, } = require('internal/errors'); const { validateObject } = require('internal/validators'); @@ -1174,7 +1174,7 @@ ObjectDefineProperties(Readable.prototype, { if (this._readableState) { this._readableState.readable = !!val; } - } + }, }, readableDidRead: { @@ -1182,7 +1182,7 @@ ObjectDefineProperties(Readable.prototype, { enumerable: false, get: function() { return this._readableState.dataEmitted; - } + }, }, readableAborted: { @@ -1194,7 +1194,7 @@ ObjectDefineProperties(Readable.prototype, { (this._readableState.destroyed || this._readableState.errored) && !this._readableState.endEmitted ); - } + }, }, readableHighWaterMark: { @@ -1202,7 +1202,7 @@ ObjectDefineProperties(Readable.prototype, { enumerable: false, get: function() { return this._readableState.highWaterMark; - } + }, }, readableBuffer: { @@ -1210,7 +1210,7 @@ ObjectDefineProperties(Readable.prototype, { enumerable: false, get: function() { return this._readableState && this._readableState.buffer; - } + }, }, readableFlowing: { @@ -1223,7 +1223,7 @@ ObjectDefineProperties(Readable.prototype, { if (this._readableState) { this._readableState.flowing = state; } - } + }, }, readableLength: { @@ -1231,7 +1231,7 @@ ObjectDefineProperties(Readable.prototype, { enumerable: false, get() { return this._readableState.length; - } + }, }, readableObjectMode: { @@ -1239,7 +1239,7 @@ ObjectDefineProperties(Readable.prototype, { enumerable: false, get() { return this._readableState ? this._readableState.objectMode : false; - } + }, }, readableEncoding: { @@ -1247,7 +1247,7 @@ ObjectDefineProperties(Readable.prototype, { enumerable: false, get() { return this._readableState ? this._readableState.encoding : null; - } + }, }, errored: { @@ -1255,14 +1255,14 @@ ObjectDefineProperties(Readable.prototype, { enumerable: false, get() { return this._readableState ? this._readableState.errored : null; - } + }, }, closed: { __proto__: null, get() { return this._readableState ? this._readableState.closed : false; - } + }, }, destroyed: { @@ -1281,7 +1281,7 @@ ObjectDefineProperties(Readable.prototype, { // Backward compatibility, the user is explicitly // managing destroyed. this._readableState.destroyed = value; - } + }, }, readableEnded: { @@ -1289,7 +1289,7 @@ ObjectDefineProperties(Readable.prototype, { enumerable: false, get() { return this._readableState ? this._readableState.endEmitted : false; - } + }, }, }); @@ -1300,7 +1300,7 @@ ObjectDefineProperties(ReadableState.prototype, { __proto__: null, get() { return this.pipes.length; - } + }, }, // Legacy property for `paused`. @@ -1311,8 +1311,8 @@ ObjectDefineProperties(ReadableState.prototype, { }, set(value) { this[kPaused] = !!value; - } - } + }, + }, }); // Exposed for testing purposes only. @@ -1426,6 +1426,6 @@ Readable.wrap = function(src, options) { destroy(err, callback) { destroyImpl.destroyer(src, err); callback(err); - } + }, }).wrap(src); }; diff --git a/lib/internal/streams/state.js b/lib/internal/streams/state.js index 83050a62f9cedc..7b05a1ab0b5a51 100644 --- a/lib/internal/streams/state.js +++ b/lib/internal/streams/state.js @@ -32,5 +32,5 @@ function getHighWaterMark(state, options, duplexKey, isDuplex) { module.exports = { getHighWaterMark, - getDefaultHighWaterMark + getDefaultHighWaterMark, }; diff --git a/lib/internal/streams/transform.js b/lib/internal/streams/transform.js index ddd21f0fba9122..2527ce94c8f44d 100644 --- a/lib/internal/streams/transform.js +++ b/lib/internal/streams/transform.js @@ -70,7 +70,7 @@ const { module.exports = Transform; const { - ERR_METHOD_NOT_IMPLEMENTED + ERR_METHOD_NOT_IMPLEMENTED, } = require('internal/errors').codes; const Duplex = require('internal/streams/duplex'); const { getHighWaterMark } = require('internal/streams/state'); @@ -99,7 +99,7 @@ function Transform(options) { // a "bug" where we check needDrain before calling _write and not after. // Refs: https://github.com/nodejs/node/pull/32887 // Refs: https://github.com/nodejs/node/pull/35941 - writableHighWaterMark: options.writableHighWaterMark || 0 + writableHighWaterMark: options.writableHighWaterMark || 0, }; } diff --git a/lib/internal/streams/writable.js b/lib/internal/streams/writable.js index 5d01c854fbd16d..718d4e48478677 100644 --- a/lib/internal/streams/writable.js +++ b/lib/internal/streams/writable.js @@ -51,7 +51,7 @@ const { const { getHighWaterMark, - getDefaultHighWaterMark + getDefaultHighWaterMark, } = require('internal/streams/state'); const { ERR_INVALID_ARG_TYPE, @@ -62,7 +62,7 @@ const { ERR_STREAM_ALREADY_FINISHED, ERR_STREAM_NULL_VALUES, ERR_STREAM_WRITE_AFTER_END, - ERR_UNKNOWN_ENCODING + ERR_UNKNOWN_ENCODING, } = require('internal/errors').codes; const { errorOrDestroy } = destroyImpl; @@ -221,7 +221,7 @@ ObjectDefineProperty(WritableState.prototype, 'bufferedRequestCount', { __proto__: null, get() { return this.buffered.length - this.bufferedIndex; - } + }, }); function Writable(options) { @@ -778,7 +778,7 @@ ObjectDefineProperties(Writable.prototype, { __proto__: null, get() { return this._writableState ? this._writableState.closed : false; - } + }, }, destroyed: { @@ -791,7 +791,7 @@ ObjectDefineProperties(Writable.prototype, { if (this._writableState) { this._writableState.destroyed = value; } - } + }, }, writable: { @@ -810,35 +810,35 @@ ObjectDefineProperties(Writable.prototype, { if (this._writableState) { this._writableState.writable = !!val; } - } + }, }, writableFinished: { __proto__: null, get() { return this._writableState ? this._writableState.finished : false; - } + }, }, writableObjectMode: { __proto__: null, get() { return this._writableState ? this._writableState.objectMode : false; - } + }, }, writableBuffer: { __proto__: null, get() { return this._writableState && this._writableState.getBuffer(); - } + }, }, writableEnded: { __proto__: null, get() { return this._writableState ? this._writableState.ending : false; - } + }, }, writableNeedDrain: { @@ -847,28 +847,28 @@ ObjectDefineProperties(Writable.prototype, { const wState = this._writableState; if (!wState) return false; return !wState.destroyed && !wState.ending && wState.needDrain; - } + }, }, writableHighWaterMark: { __proto__: null, get() { return this._writableState && this._writableState.highWaterMark; - } + }, }, writableCorked: { __proto__: null, get() { return this._writableState ? this._writableState.corked : 0; - } + }, }, writableLength: { __proto__: null, get() { return this._writableState && this._writableState.length; - } + }, }, errored: { @@ -876,7 +876,7 @@ ObjectDefineProperties(Writable.prototype, { enumerable: false, get() { return this._writableState ? this._writableState.errored : null; - } + }, }, writableAborted: { @@ -888,7 +888,7 @@ ObjectDefineProperties(Writable.prototype, { (this._writableState.destroyed || this._writableState.errored) && !this._writableState.finished ); - } + }, }, });