MCPcopy Index your code
hub / github.com/nodejs/node / createDependentPromises

Function createDependentPromises

test/parallel/test-stream-map.js:11–28  ·  view source on GitHub ↗
(n)

Source from the content-addressed store, hash-verified

9const { setTimeout } = require('timers/promises');
10
11function createDependentPromises(n) {
12 const promiseAndResolveArray = [];
13
14 for (let i = 0; i < n; i++) {
15 let res;
16 const promise = new Promise((resolve) => {
17 if (i === 0) {
18 res = resolve;
19 return;
20 }
21 res = () => promiseAndResolveArray[i - 1][0].then(resolve);
22 });
23
24 promiseAndResolveArray.push([promise, res]);
25 }
26
27 return promiseAndResolveArray;
28}
29
30{
31 // Map works on synchronous streams with a synchronous mapper

Callers 1

test-stream-map.jsFile · 0.85

Calls 2

thenMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…