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 4d73ea7

Browse filesBrowse files
deokjinkimRafaelGSS
authored andcommitted
lib: use kEmptyObject and update JSDoc in webstreams
Use kEmptyObject as default value of strategy. Plus, make reason and chunk as optional. And refactor to use validateBuffer. Refs: https://github.com/nodejs/node/blob/main/doc/api/webstreams.md#transformstreamdefaultcontrollerenqueuechunk Refs: https://github.com/nodejs/node/blob/main/doc/api/webstreams.md#transformstreamdefaultcontrollererrorreason Refs: https://github.com/nodejs/node/blob/main/doc/api/webstreams.md#writablestreamdefaultwriterabortreason Refs: https://github.com/nodejs/node/blob/main/doc/api/webstreams.md#writablestreamdefaultwriterwritechunk PR-URL: #46183 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
1 parent 1015a60 commit 4d73ea7
Copy full SHA for 4d73ea7

File tree

Expand file treeCollapse file tree

3 files changed

+10
-17
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+10
-17
lines changed
Open diff view settings
Collapse file

‎lib/internal/webstreams/readablestream.js‎

Copy file name to clipboardExpand all lines: lib/internal/webstreams/readablestream.js
+1-10Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,16 +1132,7 @@ class ReadableByteStreamController {
11321132
enqueue(chunk) {
11331133
if (!isReadableByteStreamController(this))
11341134
throw new ERR_INVALID_THIS('ReadableByteStreamController');
1135-
if (!isArrayBufferView(chunk)) {
1136-
throw new ERR_INVALID_ARG_TYPE(
1137-
'chunk',
1138-
[
1139-
'Buffer',
1140-
'TypedArray',
1141-
'DataView',
1142-
],
1143-
chunk);
1144-
}
1135+
validateBuffer(chunk);
11451136
const chunkByteLength = ArrayBufferViewGetByteLength(chunk);
11461137
const chunkBuffer = ArrayBufferViewGetBuffer(chunk);
11471138
const chunkBufferByteLength = ArrayBufferPrototypeGetByteLength(chunkBuffer);
Collapse file

‎lib/internal/webstreams/transformstream.js‎

Copy file name to clipboardExpand all lines: lib/internal/webstreams/transformstream.js
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const {
2626
const {
2727
createDeferredPromise,
2828
customInspectSymbol: kInspect,
29+
kEmptyObject,
2930
kEnumerableProperty,
3031
} = require('internal/util');
3132

@@ -117,8 +118,8 @@ class TransformStream {
117118
*/
118119
constructor(
119120
transformer = null,
120-
writableStrategy = {},
121-
readableStrategy = {}) {
121+
writableStrategy = kEmptyObject,
122+
readableStrategy = kEmptyObject) {
122123
const readableType = transformer?.readableType;
123124
const writableType = transformer?.writableType;
124125
const start = transformer?.start;
@@ -292,7 +293,7 @@ class TransformStreamDefaultController {
292293
}
293294

294295
/**
295-
* @param {any} chunk
296+
* @param {any} [chunk]
296297
*/
297298
enqueue(chunk = undefined) {
298299
if (!isTransformStreamDefaultController(this))
@@ -301,7 +302,7 @@ class TransformStreamDefaultController {
301302
}
302303

303304
/**
304-
* @param {any} reason
305+
* @param {any} [reason]
305306
*/
306307
error(reason = undefined) {
307308
if (!isTransformStreamDefaultController(this))
Collapse file

‎lib/internal/webstreams/writablestream.js‎

Copy file name to clipboardExpand all lines: lib/internal/webstreams/writablestream.js
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const {
3333
const {
3434
createDeferredPromise,
3535
customInspectSymbol: kInspect,
36+
kEmptyObject,
3637
kEnumerableProperty,
3738
SideEffectFreeRegExpPrototypeSymbolReplace,
3839
} = require('internal/util');
@@ -148,7 +149,7 @@ class WritableStream {
148149
* @param {UnderlyingSink} [sink]
149150
* @param {QueuingStrategy} [strategy]
150151
*/
151-
constructor(sink = null, strategy = {}) {
152+
constructor(sink = null, strategy = kEmptyObject) {
152153
const type = sink?.type;
153154
if (type !== undefined)
154155
throw new ERR_INVALID_ARG_VALUE.RangeError('type', type);
@@ -217,7 +218,7 @@ class WritableStream {
217218
}
218219

219220
/**
220-
* @param {any} reason
221+
* @param {any} [reason]
221222
* @returns {Promise<void>}
222223
*/
223224
abort(reason = undefined) {
@@ -475,7 +476,7 @@ class WritableStreamDefaultWriter {
475476
}
476477

477478
/**
478-
* @param {any} chunk
479+
* @param {any} [chunk]
479480
* @returns {Promise<void>}
480481
*/
481482
write(chunk = undefined) {

0 commit comments

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