From a5d18304f1c84d9a7de2975ed15c71ccf1f3dee8 Mon Sep 17 00:00:00 2001 From: Mattias Buelens Date: Sun, 14 Jan 2024 22:45:50 +0100 Subject: [PATCH] Remove IteratorComplete and IteratorValue --- src/lib/abstract-ops/ecmascript.ts | 11 ----------- src/lib/readable-stream/from.ts | 6 +++--- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/lib/abstract-ops/ecmascript.ts b/src/lib/abstract-ops/ecmascript.ts index 6a07db4..1416fbf 100644 --- a/src/lib/abstract-ops/ecmascript.ts +++ b/src/lib/abstract-ops/ecmascript.ts @@ -168,14 +168,3 @@ export function IteratorNext(iteratorRecord: AsyncIteratorRecord): Promise return result; } -export function IteratorComplete( - iterResult: IteratorResult -): iterResult is IteratorReturnResult { - assert(typeIsObject(iterResult)); - return Boolean(iterResult.done); -} - -export function IteratorValue(iterResult: IteratorYieldResult): T { - assert(typeIsObject(iterResult)); - return iterResult.value; -} diff --git a/src/lib/readable-stream/from.ts b/src/lib/readable-stream/from.ts index 2d0f0a6..53d1194 100644 --- a/src/lib/readable-stream/from.ts +++ b/src/lib/readable-stream/from.ts @@ -5,7 +5,7 @@ import { type ReadableStreamLike } from './readable-stream-like'; import { ReadableStreamDefaultControllerClose, ReadableStreamDefaultControllerEnqueue } from './default-controller'; -import { GetIterator, GetMethod, IteratorComplete, IteratorNext, IteratorValue } from '../abstract-ops/ecmascript'; +import { GetIterator, GetMethod, IteratorNext } from '../abstract-ops/ecmascript'; import { promiseCall, promiseRejectedWith, promiseResolvedWith, transformPromiseWith } from '../helpers/webidl'; import { typeIsObject } from '../helpers/miscellaneous'; import { noop } from '../../utils'; @@ -37,11 +37,11 @@ export function ReadableStreamFromIterable(asyncIterable: Iterable | Async if (!typeIsObject(iterResult)) { throw new TypeError('The promise returned by the iterator.next() method must fulfill with an object'); } - const done = IteratorComplete(iterResult); + const done = iterResult.done; if (done) { ReadableStreamDefaultControllerClose(stream._readableStreamController); } else { - const value = IteratorValue(iterResult); + const value = iterResult.value; ReadableStreamDefaultControllerEnqueue(stream._readableStreamController, value); } });