stream: add trailing commas in stream source files

PR-URL: https://github.com/nodejs/node/pull/46686
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
This commit is contained in:
Antoine du Hamel 2023-02-18 18:53:57 +01:00 committed by GitHub
parent 109545a8fa
commit 3a648af0f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 64 additions and 63 deletions

View File

@ -290,6 +290,7 @@ overrides:
- ./internal/readme.md - ./internal/readme.md
- ./internal/repl/history.js - ./internal/repl/history.js
- ./internal/source_map/prepare_stack_trace.js - ./internal/source_map/prepare_stack_trace.js
- ./internal/streams/*.js
- ./internal/structured_clone.js - ./internal/structured_clone.js
- ./internal/test/*.js - ./internal/test/*.js
- ./internal/test_runner/**/*.js - ./internal/test_runner/**/*.js

View File

@ -175,7 +175,7 @@ module.exports = class BufferList {
// Only inspect one level. // Only inspect one level.
depth: 0, depth: 0,
// It should not recurse. // It should not recurse.
customInspect: false customInspect: false,
}); });
} }
}; };

View File

@ -14,7 +14,7 @@ const {
kDestroyed, kDestroyed,
isDestroyed, isDestroyed,
isFinished, isFinished,
isServerRequest isServerRequest,
} = require('internal/streams/utils'); } = require('internal/streams/utils');
const kDestroy = Symbol('kDestroy'); const kDestroy = Symbol('kDestroy');
@ -334,5 +334,5 @@ module.exports = {
destroyer, destroyer,
destroy, destroy,
undestroy, undestroy,
errorOrDestroy errorOrDestroy,
}; };

View File

@ -114,8 +114,8 @@ ObjectDefineProperties(Duplex.prototype, {
this._readableState.destroyed = value; this._readableState.destroyed = value;
this._writableState.destroyed = value; this._writableState.destroyed = value;
} }
} },
} },
}); });
let webStreamsAdapters; let webStreamsAdapters;

View File

@ -32,7 +32,7 @@ const {
const { AbortController } = require('internal/abort_controller'); const { AbortController } = require('internal/abort_controller');
const { const {
FunctionPrototypeCall FunctionPrototypeCall,
} = primordials; } = primordials;
// This is needed for pre node 17. // This is needed for pre node 17.
@ -91,7 +91,7 @@ module.exports = function duplexify(body, name) {
objectMode: true, objectMode: true,
write, write,
final, 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, { return from(Duplexify, body, {
// TODO (ronag): highWaterMark? // TODO (ronag): highWaterMark?
objectMode: true, objectMode: true,
writable: false writable: false,
}); });
} }
@ -192,7 +192,7 @@ module.exports = function duplexify(body, name) {
return d = new Duplexify({ return d = new Duplexify({
objectMode: true, objectMode: true,
writable: false, writable: false,
read() {} read() {},
}); });
} }
@ -236,7 +236,7 @@ function fromAsyncGen(fn) {
destroy(err, cb) { destroy(err, cb) {
ac.abort(); ac.abort();
cb(err); cb(err);
} },
}; };
} }

View File

@ -9,7 +9,7 @@ const {
} = require('internal/errors'); } = require('internal/errors');
const { const {
ERR_INVALID_ARG_TYPE, ERR_INVALID_ARG_TYPE,
ERR_STREAM_PREMATURE_CLOSE ERR_STREAM_PREMATURE_CLOSE,
} = codes; } = codes;
const { const {
kEmptyObject, kEmptyObject,
@ -19,7 +19,7 @@ const {
validateAbortSignal, validateAbortSignal,
validateFunction, validateFunction,
validateObject, validateObject,
validateBoolean validateBoolean,
} = require('internal/validators'); } = require('internal/validators');
const { Promise, PromisePrototypeThen } = primordials; const { Promise, PromisePrototypeThen } = primordials;

View File

@ -9,7 +9,7 @@ const { Buffer } = require('buffer');
const { const {
ERR_INVALID_ARG_TYPE, ERR_INVALID_ARG_TYPE,
ERR_STREAM_NULL_VALUES ERR_STREAM_NULL_VALUES,
} = require('internal/errors').codes; } = require('internal/errors').codes;
function from(Readable, iterable, opts) { function from(Readable, iterable, opts) {
@ -21,7 +21,7 @@ function from(Readable, iterable, opts) {
read() { read() {
this.push(iterable); this.push(iterable);
this.push(null); this.push(null);
} },
}); });
} }

View File

@ -12,7 +12,7 @@ const {
const stream = require('stream'); const stream = require('stream');
const { const {
getDefaultEncoding getDefaultEncoding,
} = require('internal/crypto/util'); } = require('internal/crypto/util');
module.exports = LazyTransform; module.exports = LazyTransform;
@ -43,7 +43,7 @@ function makeSetter(name) {
value: val, value: val,
enumerable: true, enumerable: true,
configurable: true, configurable: true,
writable: true writable: true,
}); });
}; };
} }
@ -54,13 +54,13 @@ ObjectDefineProperties(LazyTransform.prototype, {
get: makeGetter('_readableState'), get: makeGetter('_readableState'),
set: makeSetter('_readableState'), set: makeSetter('_readableState'),
configurable: true, configurable: true,
enumerable: true enumerable: true,
}, },
_writableState: { _writableState: {
__proto__: null, __proto__: null,
get: makeGetter('_writableState'), get: makeGetter('_writableState'),
set: makeSetter('_writableState'), set: makeSetter('_writableState'),
configurable: true, configurable: true,
enumerable: true enumerable: true,
} },
}); });

View File

@ -27,7 +27,7 @@ const {
const { const {
validateFunction, validateFunction,
validateAbortSignal validateAbortSignal,
} = require('internal/validators'); } = require('internal/validators');
const { const {
@ -60,7 +60,7 @@ function destroyer(stream, reading, writing) {
finished = true; finished = true;
destroyImpl.destroyer(stream, err || new ERR_STREAM_DESTROYED('pipe')); destroyImpl.destroyer(stream, err || new ERR_STREAM_DESTROYED('pipe'));
}, },
cleanup cleanup,
}; };
} }
@ -314,7 +314,7 @@ function pipelineImpl(streams, callback, opts) {
// composed through `.pipe(stream)`. // composed through `.pipe(stream)`.
const pt = new PassThrough({ const pt = new PassThrough({
objectMode: true objectMode: true,
}); });
// Handle Promises/A+ spec, `then` could be a getter that throws on // Handle Promises/A+ spec, `then` could be a getter that throws on

View File

@ -32,7 +32,7 @@ const {
Promise, Promise,
SafeSet, SafeSet,
SymbolAsyncIterator, SymbolAsyncIterator,
Symbol Symbol,
} = primordials; } = primordials;
module.exports = Readable; module.exports = Readable;
@ -54,7 +54,7 @@ const BufferList = require('internal/streams/buffer_list');
const destroyImpl = require('internal/streams/destroy'); const destroyImpl = require('internal/streams/destroy');
const { const {
getHighWaterMark, getHighWaterMark,
getDefaultHighWaterMark getDefaultHighWaterMark,
} = require('internal/streams/state'); } = require('internal/streams/state');
const { const {
@ -65,8 +65,8 @@ const {
ERR_OUT_OF_RANGE, ERR_OUT_OF_RANGE,
ERR_STREAM_PUSH_AFTER_EOF, ERR_STREAM_PUSH_AFTER_EOF,
ERR_STREAM_UNSHIFT_AFTER_END_EVENT, ERR_STREAM_UNSHIFT_AFTER_END_EVENT,
ERR_UNKNOWN_ENCODING ERR_UNKNOWN_ENCODING,
} },
} = require('internal/errors'); } = require('internal/errors');
const { validateObject } = require('internal/validators'); const { validateObject } = require('internal/validators');
@ -1174,7 +1174,7 @@ ObjectDefineProperties(Readable.prototype, {
if (this._readableState) { if (this._readableState) {
this._readableState.readable = !!val; this._readableState.readable = !!val;
} }
} },
}, },
readableDidRead: { readableDidRead: {
@ -1182,7 +1182,7 @@ ObjectDefineProperties(Readable.prototype, {
enumerable: false, enumerable: false,
get: function() { get: function() {
return this._readableState.dataEmitted; return this._readableState.dataEmitted;
} },
}, },
readableAborted: { readableAborted: {
@ -1194,7 +1194,7 @@ ObjectDefineProperties(Readable.prototype, {
(this._readableState.destroyed || this._readableState.errored) && (this._readableState.destroyed || this._readableState.errored) &&
!this._readableState.endEmitted !this._readableState.endEmitted
); );
} },
}, },
readableHighWaterMark: { readableHighWaterMark: {
@ -1202,7 +1202,7 @@ ObjectDefineProperties(Readable.prototype, {
enumerable: false, enumerable: false,
get: function() { get: function() {
return this._readableState.highWaterMark; return this._readableState.highWaterMark;
} },
}, },
readableBuffer: { readableBuffer: {
@ -1210,7 +1210,7 @@ ObjectDefineProperties(Readable.prototype, {
enumerable: false, enumerable: false,
get: function() { get: function() {
return this._readableState && this._readableState.buffer; return this._readableState && this._readableState.buffer;
} },
}, },
readableFlowing: { readableFlowing: {
@ -1223,7 +1223,7 @@ ObjectDefineProperties(Readable.prototype, {
if (this._readableState) { if (this._readableState) {
this._readableState.flowing = state; this._readableState.flowing = state;
} }
} },
}, },
readableLength: { readableLength: {
@ -1231,7 +1231,7 @@ ObjectDefineProperties(Readable.prototype, {
enumerable: false, enumerable: false,
get() { get() {
return this._readableState.length; return this._readableState.length;
} },
}, },
readableObjectMode: { readableObjectMode: {
@ -1239,7 +1239,7 @@ ObjectDefineProperties(Readable.prototype, {
enumerable: false, enumerable: false,
get() { get() {
return this._readableState ? this._readableState.objectMode : false; return this._readableState ? this._readableState.objectMode : false;
} },
}, },
readableEncoding: { readableEncoding: {
@ -1247,7 +1247,7 @@ ObjectDefineProperties(Readable.prototype, {
enumerable: false, enumerable: false,
get() { get() {
return this._readableState ? this._readableState.encoding : null; return this._readableState ? this._readableState.encoding : null;
} },
}, },
errored: { errored: {
@ -1255,14 +1255,14 @@ ObjectDefineProperties(Readable.prototype, {
enumerable: false, enumerable: false,
get() { get() {
return this._readableState ? this._readableState.errored : null; return this._readableState ? this._readableState.errored : null;
} },
}, },
closed: { closed: {
__proto__: null, __proto__: null,
get() { get() {
return this._readableState ? this._readableState.closed : false; return this._readableState ? this._readableState.closed : false;
} },
}, },
destroyed: { destroyed: {
@ -1281,7 +1281,7 @@ ObjectDefineProperties(Readable.prototype, {
// Backward compatibility, the user is explicitly // Backward compatibility, the user is explicitly
// managing destroyed. // managing destroyed.
this._readableState.destroyed = value; this._readableState.destroyed = value;
} },
}, },
readableEnded: { readableEnded: {
@ -1289,7 +1289,7 @@ ObjectDefineProperties(Readable.prototype, {
enumerable: false, enumerable: false,
get() { get() {
return this._readableState ? this._readableState.endEmitted : false; return this._readableState ? this._readableState.endEmitted : false;
} },
}, },
}); });
@ -1300,7 +1300,7 @@ ObjectDefineProperties(ReadableState.prototype, {
__proto__: null, __proto__: null,
get() { get() {
return this.pipes.length; return this.pipes.length;
} },
}, },
// Legacy property for `paused`. // Legacy property for `paused`.
@ -1311,8 +1311,8 @@ ObjectDefineProperties(ReadableState.prototype, {
}, },
set(value) { set(value) {
this[kPaused] = !!value; this[kPaused] = !!value;
} },
} },
}); });
// Exposed for testing purposes only. // Exposed for testing purposes only.
@ -1426,6 +1426,6 @@ Readable.wrap = function(src, options) {
destroy(err, callback) { destroy(err, callback) {
destroyImpl.destroyer(src, err); destroyImpl.destroyer(src, err);
callback(err); callback(err);
} },
}).wrap(src); }).wrap(src);
}; };

View File

@ -32,5 +32,5 @@ function getHighWaterMark(state, options, duplexKey, isDuplex) {
module.exports = { module.exports = {
getHighWaterMark, getHighWaterMark,
getDefaultHighWaterMark getDefaultHighWaterMark,
}; };

View File

@ -70,7 +70,7 @@ const {
module.exports = Transform; module.exports = Transform;
const { const {
ERR_METHOD_NOT_IMPLEMENTED ERR_METHOD_NOT_IMPLEMENTED,
} = require('internal/errors').codes; } = require('internal/errors').codes;
const Duplex = require('internal/streams/duplex'); const Duplex = require('internal/streams/duplex');
const { getHighWaterMark } = require('internal/streams/state'); 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. // 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/32887
// Refs: https://github.com/nodejs/node/pull/35941 // Refs: https://github.com/nodejs/node/pull/35941
writableHighWaterMark: options.writableHighWaterMark || 0 writableHighWaterMark: options.writableHighWaterMark || 0,
}; };
} }

View File

@ -51,7 +51,7 @@ const {
const { const {
getHighWaterMark, getHighWaterMark,
getDefaultHighWaterMark getDefaultHighWaterMark,
} = require('internal/streams/state'); } = require('internal/streams/state');
const { const {
ERR_INVALID_ARG_TYPE, ERR_INVALID_ARG_TYPE,
@ -62,7 +62,7 @@ const {
ERR_STREAM_ALREADY_FINISHED, ERR_STREAM_ALREADY_FINISHED,
ERR_STREAM_NULL_VALUES, ERR_STREAM_NULL_VALUES,
ERR_STREAM_WRITE_AFTER_END, ERR_STREAM_WRITE_AFTER_END,
ERR_UNKNOWN_ENCODING ERR_UNKNOWN_ENCODING,
} = require('internal/errors').codes; } = require('internal/errors').codes;
const { errorOrDestroy } = destroyImpl; const { errorOrDestroy } = destroyImpl;
@ -221,7 +221,7 @@ ObjectDefineProperty(WritableState.prototype, 'bufferedRequestCount', {
__proto__: null, __proto__: null,
get() { get() {
return this.buffered.length - this.bufferedIndex; return this.buffered.length - this.bufferedIndex;
} },
}); });
function Writable(options) { function Writable(options) {
@ -778,7 +778,7 @@ ObjectDefineProperties(Writable.prototype, {
__proto__: null, __proto__: null,
get() { get() {
return this._writableState ? this._writableState.closed : false; return this._writableState ? this._writableState.closed : false;
} },
}, },
destroyed: { destroyed: {
@ -791,7 +791,7 @@ ObjectDefineProperties(Writable.prototype, {
if (this._writableState) { if (this._writableState) {
this._writableState.destroyed = value; this._writableState.destroyed = value;
} }
} },
}, },
writable: { writable: {
@ -810,35 +810,35 @@ ObjectDefineProperties(Writable.prototype, {
if (this._writableState) { if (this._writableState) {
this._writableState.writable = !!val; this._writableState.writable = !!val;
} }
} },
}, },
writableFinished: { writableFinished: {
__proto__: null, __proto__: null,
get() { get() {
return this._writableState ? this._writableState.finished : false; return this._writableState ? this._writableState.finished : false;
} },
}, },
writableObjectMode: { writableObjectMode: {
__proto__: null, __proto__: null,
get() { get() {
return this._writableState ? this._writableState.objectMode : false; return this._writableState ? this._writableState.objectMode : false;
} },
}, },
writableBuffer: { writableBuffer: {
__proto__: null, __proto__: null,
get() { get() {
return this._writableState && this._writableState.getBuffer(); return this._writableState && this._writableState.getBuffer();
} },
}, },
writableEnded: { writableEnded: {
__proto__: null, __proto__: null,
get() { get() {
return this._writableState ? this._writableState.ending : false; return this._writableState ? this._writableState.ending : false;
} },
}, },
writableNeedDrain: { writableNeedDrain: {
@ -847,28 +847,28 @@ ObjectDefineProperties(Writable.prototype, {
const wState = this._writableState; const wState = this._writableState;
if (!wState) return false; if (!wState) return false;
return !wState.destroyed && !wState.ending && wState.needDrain; return !wState.destroyed && !wState.ending && wState.needDrain;
} },
}, },
writableHighWaterMark: { writableHighWaterMark: {
__proto__: null, __proto__: null,
get() { get() {
return this._writableState && this._writableState.highWaterMark; return this._writableState && this._writableState.highWaterMark;
} },
}, },
writableCorked: { writableCorked: {
__proto__: null, __proto__: null,
get() { get() {
return this._writableState ? this._writableState.corked : 0; return this._writableState ? this._writableState.corked : 0;
} },
}, },
writableLength: { writableLength: {
__proto__: null, __proto__: null,
get() { get() {
return this._writableState && this._writableState.length; return this._writableState && this._writableState.length;
} },
}, },
errored: { errored: {
@ -876,7 +876,7 @@ ObjectDefineProperties(Writable.prototype, {
enumerable: false, enumerable: false,
get() { get() {
return this._writableState ? this._writableState.errored : null; return this._writableState ? this._writableState.errored : null;
} },
}, },
writableAborted: { writableAborted: {
@ -888,7 +888,7 @@ ObjectDefineProperties(Writable.prototype, {
(this._writableState.destroyed || this._writableState.errored) && (this._writableState.destroyed || this._writableState.errored) &&
!this._writableState.finished !this._writableState.finished
); );
} },
}, },
}); });