diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-04-16 14:09:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-16 14:09:07 +0200 |
commit | 0bb96cde726127291dccb62145e76a50b2efcd2f (patch) | |
tree | e18e2512369c5c1393c2e45efef594e1e8ca4af5 /ext/web/06_streams.js | |
parent | 8b31fc23cd80de9baa62535e95367da7a21c9cfd (diff) |
refactor: update runtime code for primordial check x in y (#13642)
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
Diffstat (limited to 'ext/web/06_streams.js')
-rw-r--r-- | ext/web/06_streams.js | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/ext/web/06_streams.js b/ext/web/06_streams.js index 7ef5a6131..6daea0898 100644 --- a/ext/web/06_streams.js +++ b/ext/web/06_streams.js @@ -41,6 +41,7 @@ PromiseResolve, queueMicrotask, RangeError, + ReflectHas, SharedArrayBuffer, Symbol, SymbolAsyncIterator, @@ -190,7 +191,7 @@ * @returns {boolean} */ function isDetachedBuffer(O) { - return isFakeDetached in O; + return ReflectHas(O, isFakeDetached); } /** @@ -392,7 +393,10 @@ * @returns {T} */ function dequeueValue(container) { - assert(_queue in container && _queueTotalSize in container); + assert( + ReflectHas(container, _queue) && + ReflectHas(container, _queueTotalSize), + ); assert(container[_queue].length); const valueWithSize = ArrayPrototypeShift(container[_queue]); container[_queueTotalSize] -= valueWithSize.size; @@ -410,7 +414,10 @@ * @returns {void} */ function enqueueValueWithSize(container, value, size) { - assert(_queue in container && _queueTotalSize in container); + assert( + ReflectHas(container, _queue) && + ReflectHas(container, _queueTotalSize), + ); if (isNonNegativeNumber(size) === false) { throw RangeError("chunk size isn't a positive number"); } @@ -592,7 +599,7 @@ */ function isReadableStream(value) { return !(typeof value !== "object" || value === null || - !(_controller in value)); + !ReflectHas(value, _controller)); } /** @@ -612,7 +619,7 @@ */ function isReadableStreamDefaultReader(value) { return !(typeof value !== "object" || value === null || - !(_readRequests in value)); + !ReflectHas(value, _readRequests)); } /** @@ -621,7 +628,7 @@ */ function isReadableStreamBYOBReader(value) { return !(typeof value !== "object" || value === null || - !(_readIntoRequests in value)); + !ReflectHas(value, _readIntoRequests)); } /** @@ -639,7 +646,7 @@ */ function isWritableStream(value) { return !(typeof value !== "object" || value === null || - !(_controller in value)); + !ReflectHas(value, _controller)); } /** @@ -659,7 +666,10 @@ * @returns {T | _close} */ function peekQueueValue(container) { - assert(_queue in container && _queueTotalSize in container); + assert( + ReflectHas(container, _queue) && + ReflectHas(container, _queueTotalSize), + ); assert(container[_queue].length); const valueWithSize = container[_queue][0]; return valueWithSize.value; @@ -4333,7 +4343,7 @@ highWaterMark, ); } else { - assert(!("type" in underlyingSourceDict)); + assert(!(ReflectHas(underlyingSourceDict, "type"))); const sizeAlgorithm = extractSizeAlgorithm(strategy); const highWaterMark = extractHighWaterMark(strategy, 1); setUpReadableStreamDefaultControllerFromUnderlyingSource( |