Skip to content

Commit fb08690

Browse files
committed
stream: move abort callback helper out of closure
1 parent 9e427dd commit fb08690

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

lib/internal/streams/iter/pull.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,10 @@ async function* applyValidatedStatefulAsyncTransform(source, transform, options)
610610
options.signal?.throwIfAborted();
611611
}
612612

613+
function getOnAbort(reject, signal) {
614+
return () => reject(signal.reason);
615+
}
616+
613617
/**
614618
* Read one item from an async iterator, rejecting early if the signal aborts.
615619
* @param {AsyncIterator} iterator - The iterator to read from.
@@ -625,7 +629,7 @@ function abortableNext(iterator, signal) {
625629

626630
const next = iterator.next();
627631
const { promise, reject } = PromiseWithResolvers();
628-
const onAbort = () => reject(signal.reason);
632+
const onAbort = getOnAbort(reject, signal);
629633
signal.addEventListener('abort', onAbort, { __proto__: null, once: true });
630634
if (signal.aborted) {
631635
onAbort();

0 commit comments

Comments
 (0)