Skip to content

Commit

Permalink
Use promiseCall
Browse files Browse the repository at this point in the history
  • Loading branch information
MattiasBuelens committed Feb 28, 2024
1 parent 0616eb6 commit 52778d4
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/lib/readable-stream/from.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from './readable-stream-like';
import { ReadableStreamDefaultControllerClose, ReadableStreamDefaultControllerEnqueue } from './default-controller';
import { GetIterator, GetMethod, IteratorComplete, IteratorNext, IteratorValue } from '../abstract-ops/ecmascript';
import { promiseRejectedWith, promiseResolvedWith, reflectCall, transformPromiseWith } from '../helpers/webidl';
import { promiseCall, promiseRejectedWith, promiseResolvedWith, transformPromiseWith } from '../helpers/webidl';
import { typeIsObject } from '../helpers/miscellaneous';
import { noop } from '../../utils';

Expand Down Expand Up @@ -58,13 +58,7 @@ export function ReadableStreamFromIterable<R>(asyncIterable: Iterable<R> | Async
if (returnMethod === undefined) {
return promiseResolvedWith(undefined);
}
let returnResult: IteratorResult<R> | Promise<IteratorResult<R>>;
try {
returnResult = reflectCall(returnMethod, iterator, [reason]);
} catch (e) {
return promiseRejectedWith(e);
}
const returnPromise = promiseResolvedWith(returnResult);
const returnPromise = promiseCall(returnMethod, iterator, [reason]);
return transformPromiseWith(returnPromise, iterResult => {
if (!typeIsObject(iterResult)) {
throw new TypeError('The promise returned by the iterator.return() method must fulfill with an object');
Expand Down

0 comments on commit 52778d4

Please sign in to comment.