GeezerVison is showing github.com — lib: use kEmptyObject and update JSDoc in webstreams · nodejs/node@4d73ea7
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/internal/webstreams/readablestream.js +1-10Lines changed: 1 addition & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1132,16 +1132,7 @@ class ReadableByteStreamController { | 1132 | 1132 | enqueue(chunk) { | 1133 | 1133 | if (!isReadableByteStreamController(this)) | 1134 | 1134 | 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); | 1145 | 1136 | const chunkByteLength = ArrayBufferViewGetByteLength(chunk); | 1146 | 1137 | const chunkBuffer = ArrayBufferViewGetBuffer(chunk); | 1147 | 1138 | const chunkBufferByteLength = ArrayBufferPrototypeGetByteLength(chunkBuffer); | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/webstreams/transformstream.js +5-4Lines changed: 5 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -26,6 +26,7 @@ const { | 26 | 26 | const { | 27 | 27 | createDeferredPromise, | 28 | 28 | customInspectSymbol: kInspect, | | 29 | + kEmptyObject, | 29 | 30 | kEnumerableProperty, | 30 | 31 | } = require('internal/util'); | 31 | 32 |
| @@ -117,8 +118,8 @@ class TransformStream { | 117 | 118 | */ | 118 | 119 | constructor( | 119 | 120 | transformer = null, | 120 | | - writableStrategy = {}, | 121 | | - readableStrategy = {}) { | | 121 | + writableStrategy = kEmptyObject, | | 122 | + readableStrategy = kEmptyObject) { | 122 | 123 | const readableType = transformer?.readableType; | 123 | 124 | const writableType = transformer?.writableType; | 124 | 125 | const start = transformer?.start; | @@ -292,7 +293,7 @@ class TransformStreamDefaultController { | 292 | 293 | } | 293 | 294 |
| 294 | 295 | /** | 295 | | - * @param {any} chunk | | 296 | + * @param {any} [chunk] | 296 | 297 | */ | 297 | 298 | enqueue(chunk = undefined) { | 298 | 299 | if (!isTransformStreamDefaultController(this)) | @@ -301,7 +302,7 @@ class TransformStreamDefaultController { | 301 | 302 | } | 302 | 303 |
| 303 | 304 | /** | 304 | | - * @param {any} reason | | 305 | + * @param {any} [reason] | 305 | 306 | */ | 306 | 307 | error(reason = undefined) { | 307 | 308 | if (!isTransformStreamDefaultController(this)) | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/webstreams/writablestream.js +4-3Lines changed: 4 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -33,6 +33,7 @@ const { | 33 | 33 | const { | 34 | 34 | createDeferredPromise, | 35 | 35 | customInspectSymbol: kInspect, | | 36 | + kEmptyObject, | 36 | 37 | kEnumerableProperty, | 37 | 38 | SideEffectFreeRegExpPrototypeSymbolReplace, | 38 | 39 | } = require('internal/util'); | @@ -148,7 +149,7 @@ class WritableStream { | 148 | 149 | * @param {UnderlyingSink} [sink] | 149 | 150 | * @param {QueuingStrategy} [strategy] | 150 | 151 | */ | 151 | | - constructor(sink = null, strategy = {}) { | | 152 | + constructor(sink = null, strategy = kEmptyObject) { | 152 | 153 | const type = sink?.type; | 153 | 154 | if (type !== undefined) | 154 | 155 | throw new ERR_INVALID_ARG_VALUE.RangeError('type', type); | @@ -217,7 +218,7 @@ class WritableStream { | 217 | 218 | } | 218 | 219 |
| 219 | 220 | /** | 220 | | - * @param {any} reason | | 221 | + * @param {any} [reason] | 221 | 222 | * @returns {Promise<void>} | 222 | 223 | */ | 223 | 224 | abort(reason = undefined) { | @@ -475,7 +476,7 @@ class WritableStreamDefaultWriter { | 475 | 476 | } | 476 | 477 |
| 477 | 478 | /** | 478 | | - * @param {any} chunk | | 479 | + * @param {any} [chunk] | 479 | 480 | * @returns {Promise<void>} | 480 | 481 | */ | 481 | 482 | write(chunk = undefined) { | |
|