From 52778d48645de4d19e08ccfcc936608d8c477e06 Mon Sep 17 00:00:00 2001 From: Mattias Buelens Date: Sun, 14 Jan 2024 22:20:08 +0100 Subject: [PATCH] Use promiseCall --- src/lib/readable-stream/from.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/lib/readable-stream/from.ts b/src/lib/readable-stream/from.ts index 1bedb61..2d0f0a6 100644 --- a/src/lib/readable-stream/from.ts +++ b/src/lib/readable-stream/from.ts @@ -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'; @@ -58,13 +58,7 @@ export function ReadableStreamFromIterable(asyncIterable: Iterable | Async if (returnMethod === undefined) { return promiseResolvedWith(undefined); } - let returnResult: IteratorResult | Promise>; - 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');