Skip to content

Commit

Permalink
Remove IteratorComplete and IteratorValue
Browse files Browse the repository at this point in the history
  • Loading branch information
MattiasBuelens committed Feb 28, 2024
1 parent 52778d4 commit a5d1830
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
11 changes: 0 additions & 11 deletions src/lib/abstract-ops/ecmascript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,3 @@ export function IteratorNext<T>(iteratorRecord: AsyncIteratorRecord<T>): Promise
return result;
}

export function IteratorComplete<TReturn>(
iterResult: IteratorResult<unknown, TReturn>
): iterResult is IteratorReturnResult<TReturn> {
assert(typeIsObject(iterResult));
return Boolean(iterResult.done);
}

export function IteratorValue<T>(iterResult: IteratorYieldResult<T>): T {
assert(typeIsObject(iterResult));
return iterResult.value;
}
6 changes: 3 additions & 3 deletions src/lib/readable-stream/from.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -37,11 +37,11 @@ export function ReadableStreamFromIterable<R>(asyncIterable: Iterable<R> | 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);
}
});
Expand Down

0 comments on commit a5d1830

Please sign in to comment.