mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
stream: simplify createPromiseCallback
Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com> PR-URL: https://github.com/nodejs/node/pull/62650 Reviewed-By: Aviv Keller <me@aviv.sh> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
This commit is contained in:
1 file changed
+2
-8
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user