GeezerVison is showing github.com — stream: consolidate non-op algorithm callbacks · nodejs/node@859ea01
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/readablestream.js +10-11Lines changed: 10 additions & 11 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -116,9 +116,8 @@ const { | 116 | 116 | kType, | 117 | 117 | lazyTransfer, | 118 | 118 | materializeQueue, | | 119 | + nonOpCallback, | 119 | 120 | nonOpCancel, | 120 | | - nonOpPull, | 121 | | - nonOpStart, | 122 | 121 | rejectedHandledRecord, | 123 | 122 | resetQueue, | 124 | 123 | resolvedRecord, | @@ -1447,7 +1446,7 @@ function readableStreamFromIterable(iterable) { | 1447 | 1446 | if (iterator === null || (typeof iterator !== 'object' && typeof iterator !== 'function')) { | 1448 | 1447 | throw new ERR_INVALID_STATE.TypeError('The iterator method must return an object'); | 1449 | 1448 | } | 1450 | | - const startAlgorithm = nonOpStart; | | 1449 | + const startAlgorithm = nonOpCallback; | 1451 | 1450 |
| 1452 | 1451 | async function pullAlgorithm() { | 1453 | 1452 | const iterResult = await iterator.next(); | @@ -1929,9 +1928,9 @@ function readableStreamDefaultTee(stream, cloneForBranch2) { | 1929 | 1928 | } | 1930 | 1929 |
| 1931 | 1930 | branch1 = | 1932 | | - createReadableStream(nonOpStart, pullAlgorithm, cancel1Algorithm); | | 1931 | + createReadableStream(nonOpCallback, pullAlgorithm, cancel1Algorithm); | 1933 | 1932 | branch2 = | 1934 | | - createReadableStream(nonOpStart, pullAlgorithm, cancel2Algorithm); | | 1933 | + createReadableStream(nonOpCallback, pullAlgorithm, cancel2Algorithm); | 1935 | 1934 |
| 1936 | 1935 | PromisePrototypeThen( | 1937 | 1936 | readerClosedPromise(reader).promise, | @@ -2217,9 +2216,9 @@ function readableByteStreamTee(stream) { | 2217 | 2216 | } | 2218 | 2217 |
| 2219 | 2218 | branch1 = | 2220 | | - createReadableByteStream(nonOpStart, pull1Algorithm, cancel1Algorithm); | | 2219 | + createReadableByteStream(nonOpCallback, pull1Algorithm, cancel1Algorithm); | 2221 | 2220 | branch2 = | 2222 | | - createReadableByteStream(nonOpStart, pull2Algorithm, cancel2Algorithm); | | 2221 | + createReadableByteStream(nonOpCallback, pull2Algorithm, cancel2Algorithm); | 2223 | 2222 |
| 2224 | 2223 | forwardReaderError(reader); | 2225 | 2224 |
| @@ -2862,10 +2861,10 @@ function setupReadableStreamDefaultControllerFromSource( | 2862 | 2861 | const cancel = source?.cancel; | 2863 | 2862 | const startAlgorithm = start ? | 2864 | 2863 | FunctionPrototypeBind(start, source, controller) : | 2865 | | - nonOpStart; | | 2864 | + nonOpCallback; | 2866 | 2865 | const pullAlgorithm = pull ? | 2867 | 2866 | createRawCallback1Param('source.pull', pull, source) : | 2868 | | - nonOpPull; | | 2867 | + nonOpCallback; | 2869 | 2868 | const cancelAlgorithm = cancel ? | 2870 | 2869 | createPromiseCallback1Param('source.cancel', cancel, source) : | 2871 | 2870 | nonOpCancel; | @@ -3743,10 +3742,10 @@ function setupReadableByteStreamControllerFromSource( | 3743 | 3742 | const autoAllocateChunkSize = source?.autoAllocateChunkSize; | 3744 | 3743 | const startAlgorithm = start ? | 3745 | 3744 | FunctionPrototypeBind(start, source, controller) : | 3746 | | - nonOpStart; | | 3745 | + nonOpCallback; | 3747 | 3746 | const pullAlgorithm = pull ? | 3748 | 3747 | createRawCallback1Param('source.pull', pull, source) : | 3749 | | - nonOpPull; | | 3748 | + nonOpCallback; | 3750 | 3749 | const cancelAlgorithm = cancel ? | 3751 | 3750 | createPromiseCallback1Param('source.cancel', cancel, source) : | 3752 | 3751 | nonOpCancel; | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/webstreams/util.js +6-10Lines changed: 6 additions & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -418,17 +418,14 @@ function setPromiseHandled(promise) { | 418 | 418 |
| 419 | 419 | async function nonOpFlush() {} | 420 | 420 |
| 421 | | -function nonOpStart() {} | 422 | | - | 423 | | -// nonOpPull and nonOpWrite are raw callbacks (see createRawCallback*): | 424 | | -// their non-thenable return takes the allocation-free fast path in | | 421 | +// Shared non-op for the start/pull/write algorithm callbacks, which all | | 422 | +// follow the raw-callback contract (see createRawCallback*): the | | 423 | +// non-thenable return takes the allocation-free fast path in | 425 | 424 | // thenAlgorithmResult(). | 426 | | -function nonOpPull() {} | | 425 | +function nonOpCallback() {} | 427 | 426 |
| 428 | 427 | async function nonOpCancel() {} | 429 | 428 |
| 430 | | -function nonOpWrite() {} | 431 | | - | 432 | 429 | let transfer; | 433 | 430 | function lazyTransfer() { | 434 | 431 | if (transfer === undefined) | @@ -465,11 +462,10 @@ module.exports = { | 465 | 462 | kType, | 466 | 463 | lazyTransfer, | 467 | 464 | materializeQueue, | | 465 | + nonOpCallback, | 468 | 466 | nonOpCancel, | 469 | 467 | nonOpFlush, | 470 | | - nonOpPull, | 471 | | - nonOpStart, | 472 | | - nonOpWrite, | | 468 | + | 473 | 469 | peekQueueValue, | 474 | 470 | rejectedHandledRecord, | 475 | 471 | resetQueue, | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/webstreams/writablestream.js +3-4Lines changed: 3 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -70,9 +70,8 @@ const { | 70 | 70 | kState, | 71 | 71 | kType, | 72 | 72 | lazyTransfer, | | 73 | + nonOpCallback, | 73 | 74 | nonOpCancel, | 74 | | - nonOpStart, | 75 | | - nonOpWrite, | 76 | 75 | peekQueueValue, | 77 | 76 | rejectedHandledRecord, | 78 | 77 | resetQueue, | @@ -1336,10 +1335,10 @@ function setupWritableStreamDefaultControllerFromSink( | 1336 | 1335 | const abort = sink?.abort; | 1337 | 1336 | const startAlgorithm = start ? | 1338 | 1337 | FunctionPrototypeBind(start, sink, controller) : | 1339 | | - nonOpStart; | | 1338 | + nonOpCallback; | 1340 | 1339 | const writeAlgorithm = write ? | 1341 | 1340 | createRawCallback2Params('sink.write', write, sink) : | 1342 | | - nonOpWrite; | | 1341 | + nonOpCallback; | 1343 | 1342 | const closeAlgorithm = close ? | 1344 | 1343 | createPromiseCallbackNoParams('sink.close', close, sink) : | 1345 | 1344 | nonOpCancel; | |
|