Skip to content

Commit 0fea430

Browse files
authored
stream: simplify createPromiseCallback
Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com> PR-URL: #62650 Reviewed-By: Aviv Keller <me@aviv.sh> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
1 parent ef8f8f8 commit 0fea430

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

lib/internal/webstreams/util.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const {
1111
MathMax,
1212
NumberIsNaN,
1313
PromisePrototypeThen,
14+
ReflectApply,
1415
ReflectGet,
1516
Symbol,
1617
SymbolAsyncIterator,
@@ -166,15 +167,9 @@ function enqueueValueWithSize(controller, value, size) {
166167
controller[kState].queueTotalSize += size;
167168
}
168169

169-
// This implements "invoke a callback function type" for callback functions that return a promise.
170-
// See https://webidl.spec.whatwg.org/#es-invoking-callback-functions
171-
async function invokePromiseCallback(fn, thisArg, ...args) {
172-
return FunctionPrototypeCall(fn, thisArg, ...args);
173-
}
174-
175170
function createPromiseCallback(name, fn, thisArg) {
176171
validateFunction(fn, name);
177-
return (...args) => invokePromiseCallback(fn, thisArg, ...args);
172+
return async (...args) => ReflectApply(fn, thisArg, args);
178173
}
179174

180175
function isPromisePending(promise) {
@@ -281,7 +276,6 @@ module.exports = {
281276
extractHighWaterMark,
282277
extractSizeAlgorithm,
283278
lazyTransfer,
284-
invokePromiseCallback,
285279
isBrandCheck,
286280
isPromisePending,
287281
peekQueueValue,

0 commit comments

Comments
 (0)