From daa80b137cd0109526a339eb0647045ab6c2aa3d Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Thu, 9 Apr 2026 16:57:54 +0200 Subject: [PATCH] stream: simplify `createPromiseCallback` Signed-off-by: Antoine du Hamel --- lib/internal/webstreams/util.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/internal/webstreams/util.js b/lib/internal/webstreams/util.js index 5bf016f73b7af5..070fc09f17f505 100644 --- a/lib/internal/webstreams/util.js +++ b/lib/internal/webstreams/util.js @@ -11,6 +11,7 @@ const { MathMax, NumberIsNaN, PromisePrototypeThen, + ReflectApply, ReflectGet, Symbol, SymbolAsyncIterator, @@ -166,15 +167,9 @@ function enqueueValueWithSize(controller, value, size) { controller[kState].queueTotalSize += size; } -// This implements "invoke a callback function type" for callback functions that return a promise. -// See https://webidl.spec.whatwg.org/#es-invoking-callback-functions -async function invokePromiseCallback(fn, thisArg, ...args) { - return FunctionPrototypeCall(fn, thisArg, ...args); -} - function createPromiseCallback(name, fn, thisArg) { validateFunction(fn, name); - return (...args) => invokePromiseCallback(fn, thisArg, ...args); + return async (...args) => ReflectApply(fn, thisArg, args); } function isPromisePending(promise) { @@ -281,7 +276,6 @@ module.exports = { extractHighWaterMark, extractSizeAlgorithm, lazyTransfer, - invokePromiseCallback, isBrandCheck, isPromisePending, peekQueueValue,