GeezerVison is showing github.com — stream: simplify `createPromiseCallback` · nodejs/node@f00cdab
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/internal/webstreams/util.js +2-8Lines changed: 2 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -11,6 +11,7 @@ const { | 11 | 11 | MathMax, | 12 | 12 | NumberIsNaN, | 13 | 13 | PromisePrototypeThen, | | 14 | + ReflectApply, | 14 | 15 | ReflectGet, | 15 | 16 | Symbol, | 16 | 17 | SymbolAsyncIterator, | @@ -166,15 +167,9 @@ function enqueueValueWithSize(controller, value, size) { | 166 | 167 | controller[kState].queueTotalSize += size; | 167 | 168 | } | 168 | 169 |
| 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 | | - | 175 | 170 | function createPromiseCallback(name, fn, thisArg) { | 176 | 171 | validateFunction(fn, name); | 177 | | - return (...args) => invokePromiseCallback(fn, thisArg, ...args); | | 172 | + return async (...args) => ReflectApply(fn, thisArg, args); | 178 | 173 | } | 179 | 174 |
| 180 | 175 | function isPromisePending(promise) { | @@ -281,7 +276,6 @@ module.exports = { | 281 | 276 | extractHighWaterMark, | 282 | 277 | extractSizeAlgorithm, | 283 | 278 | lazyTransfer, | 284 | | - invokePromiseCallback, | 285 | 279 | isBrandCheck, | 286 | 280 | isPromisePending, | 287 | 281 | peekQueueValue, | |
|