* @param {UnderlyingSource} [source] * @param {QueuingStrategy} [strategy]
(source = kEmptyObject, strategy = kEmptyObject)
| 251 | * @param {QueuingStrategy} [strategy] |
| 252 | */ |
| 253 | constructor(source = kEmptyObject, strategy = kEmptyObject) { |
| 254 | markTransferMode(this, false, true); |
| 255 | validateObject(source, 'source', kValidateObjectAllowObjects); |
| 256 | validateObject(strategy, 'strategy', kValidateObjectAllowObjectsAndNull); |
| 257 | this[kState] = createReadableStreamState(); |
| 258 | |
| 259 | // The spec requires handling of the strategy first |
| 260 | // here. Specifically, if getting the size and |
| 261 | // highWaterMark from the strategy fail, that has |
| 262 | // to trigger a throw before getting the details |
| 263 | // from the source. So be sure to keep these in |
| 264 | // this order. |
| 265 | const size = strategy?.size; |
| 266 | const highWaterMark = strategy?.highWaterMark; |
| 267 | const type = source.type; |
| 268 | |
| 269 | if (`${type}` === 'bytes') { |
| 270 | if (size !== undefined) |
| 271 | throw new ERR_INVALID_ARG_VALUE.RangeError('strategy.size', size); |
| 272 | setupReadableByteStreamControllerFromSource( |
| 273 | this, |
| 274 | source, |
| 275 | extractHighWaterMark(highWaterMark, 0)); |
| 276 | } else { |
| 277 | if (type !== undefined) |
| 278 | throw new ERR_INVALID_ARG_VALUE('source.type', type); |
| 279 | setupReadableStreamDefaultControllerFromSource( |
| 280 | this, |
| 281 | source, |
| 282 | extractHighWaterMark(highWaterMark, 1), |
| 283 | extractSizeAlgorithm(size)); |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | get [kIsDisturbed]() { |
| 288 | return this[kState].disturbed; |
nothing calls this directly
no test coverage detected