Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b200a5f

Browse filesBrowse files
LiviaMedeirosdanielleadams
authored andcommitted
stream: use kEmptyObject
PR-URL: #43159 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 5e98cac commit b200a5f
Copy full SHA for b200a5f

File tree

Expand file treeCollapse file tree

4 files changed

+19
-13
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+19
-13
lines changed
Open diff view settings
Collapse file

‎lib/internal/streams/end-of-stream.js‎

Copy file name to clipboardExpand all lines: lib/internal/streams/end-of-stream.js
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ const {
1111
ERR_INVALID_ARG_TYPE,
1212
ERR_STREAM_PREMATURE_CLOSE
1313
} = codes;
14-
const { once } = require('internal/util');
14+
const {
15+
kEmptyObject,
16+
once,
17+
} = require('internal/util');
1518
const {
1619
validateAbortSignal,
1720
validateFunction,
@@ -43,9 +46,9 @@ const nop = () => {};
4346
function eos(stream, options, callback) {
4447
if (arguments.length === 2) {
4548
callback = options;
46-
options = {};
49+
options = kEmptyObject;
4750
} else if (options == null) {
48-
options = {};
51+
options = kEmptyObject;
4952
} else {
5053
validateObject(options, 'options');
5154
}
Collapse file

‎lib/internal/webstreams/adapters.js‎

Copy file name to clipboardExpand all lines: lib/internal/webstreams/adapters.js
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const {
5555

5656
const {
5757
createDeferredPromise,
58+
kEmptyObject,
5859
} = require('internal/util');
5960

6061
const {
@@ -198,7 +199,7 @@ function newWritableStreamFromStreamWritable(streamWritable) {
198199
* }} [options]
199200
* @returns {Writable}
200201
*/
201-
function newStreamWritableFromWritableStream(writableStream, options = {}) {
202+
function newStreamWritableFromWritableStream(writableStream, options = kEmptyObject) {
202203
if (!isWritableStream(writableStream)) {
203204
throw new ERR_INVALID_ARG_TYPE(
204205
'writableStream',
@@ -441,7 +442,7 @@ function newReadableStreamFromStreamReadable(streamReadable) {
441442
* }} [options]
442443
* @returns {Readable}
443444
*/
444-
function newStreamReadableFromReadableStream(readableStream, options = {}) {
445+
function newStreamReadableFromReadableStream(readableStream, options = kEmptyObject) {
445446
if (!isReadableStream(readableStream)) {
446447
throw new ERR_INVALID_ARG_TYPE(
447448
'readableStream',
@@ -585,7 +586,7 @@ function newReadableWritablePairFromDuplex(duplex) {
585586
* }} [options]
586587
* @returns {Duplex}
587588
*/
588-
function newStreamDuplexFromReadableWritablePair(pair = {}, options = {}) {
589+
function newStreamDuplexFromReadableWritablePair(pair = kEmptyObject, options = kEmptyObject) {
589590
validateObject(pair, 'pair');
590591
const {
591592
readable: readableStream,
@@ -876,7 +877,7 @@ function newWritableStreamFromStreamBase(streamBase, strategy) {
876877
* @param {QueuingStrategy} strategy
877878
* @returns {ReadableStream}
878879
*/
879-
function newReadableStreamFromStreamBase(streamBase, strategy, options = {}) {
880+
function newReadableStreamFromStreamBase(streamBase, strategy, options = kEmptyObject) {
880881
validateObject(streamBase, 'streamBase');
881882
validateObject(options, 'options');
882883

Collapse file

‎lib/internal/webstreams/encoding.js‎

Copy file name to clipboardExpand all lines: lib/internal/webstreams/encoding.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const {
2424

2525
const {
2626
customInspectSymbol: kInspect,
27+
kEmptyObject,
2728
kEnumerableProperty,
2829
} = require('internal/util');
2930

@@ -114,7 +115,7 @@ class TextDecoderStream {
114115
* ignoreBOM? : boolean,
115116
* }} [options]
116117
*/
117-
constructor(encoding = 'utf-8', options = {}) {
118+
constructor(encoding = 'utf-8', options = kEmptyObject) {
118119
this[kType] = 'TextDecoderStream';
119120
this[kHandle] = new TextDecoder(encoding, options);
120121
this[kTransform] = new TransformStream({
Collapse file

‎lib/internal/webstreams/readablestream.js‎

Copy file name to clipboardExpand all lines: lib/internal/webstreams/readablestream.js
+6-5Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const {
5050
const {
5151
createDeferredPromise,
5252
customInspectSymbol: kInspect,
53+
kEmptyObject,
5354
kEnumerableProperty,
5455
} = require('internal/util');
5556

@@ -206,7 +207,7 @@ class ReadableStream {
206207
* @param {UnderlyingSource} [source]
207208
* @param {QueuingStrategy} [strategy]
208209
*/
209-
constructor(source = {}, strategy = {}) {
210+
constructor(source = {}, strategy = kEmptyObject) {
210211
if (source === null)
211212
throw new ERR_INVALID_ARG_VALUE('source', 'Object', source);
212213
this[kState] = {
@@ -296,7 +297,7 @@ class ReadableStream {
296297
* }} [options]
297298
* @returns {ReadableStreamReader}
298299
*/
299-
getReader(options = {}) {
300+
getReader(options = kEmptyObject) {
300301
if (!isReadableStream(this))
301302
throw new ERR_INVALID_THIS('ReadableStream');
302303
validateObject(options, 'options', { nullable: true, allowFunction: true });
@@ -315,7 +316,7 @@ class ReadableStream {
315316
* @param {StreamPipeOptions} [options]
316317
* @returns {ReadableStream}
317318
*/
318-
pipeThrough(transform, options = {}) {
319+
pipeThrough(transform, options = kEmptyObject) {
319320
if (!isReadableStream(this))
320321
throw new ERR_INVALID_THIS('ReadableStream');
321322
const readable = transform?.readable;
@@ -365,7 +366,7 @@ class ReadableStream {
365366
* @param {StreamPipeOptions} [options]
366367
* @returns {Promise<void>}
367368
*/
368-
pipeTo(destination, options = {}) {
369+
pipeTo(destination, options = kEmptyObject) {
369370
try {
370371
if (!isReadableStream(this))
371372
throw new ERR_INVALID_THIS('ReadableStream');
@@ -416,7 +417,7 @@ class ReadableStream {
416417
* }} [options]
417418
* @returns {AsyncIterable}
418419
*/
419-
values(options = {}) {
420+
values(options = kEmptyObject) {
420421
if (!isReadableStream(this))
421422
throw new ERR_INVALID_THIS('ReadableStream');
422423
validateObject(options, 'options');

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.