From 450e0519d9f05aa53c3613bf2bb7ffd9b962fd5f Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sat, 11 Apr 2026 17:45:39 +0200 Subject: [PATCH] stream: simplify `createPromiseCallback` Signed-off-by: Antoine du Hamel PR-URL: https://github.com/nodejs/node/pull/62650 Reviewed-By: Aviv Keller Reviewed-By: Luigi Pinca Reviewed-By: Filip Skokan --- 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 5bf016f73b7..070fc09f17f 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,