MCPcopy Create free account
hub / github.com/nodejs/node / testShareSyncMultipleConsumers

Function testShareSyncMultipleConsumers

test/parallel/test-stream-iter-share-sync.js:25–43  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23}
24
25async function testShareSyncMultipleConsumers() {
26 const enc = new TextEncoder();
27 function* gen() {
28 yield [enc.encode('a')];
29 yield [enc.encode('b')];
30 yield [enc.encode('c')];
31 }
32
33 const shared = shareSync(gen(), { highWaterMark: 16 });
34
35 const c1 = shared.pull();
36 const c2 = shared.pull();
37
38 const data1 = textSync(c1);
39 const data2 = textSync(c2);
40
41 assert.strictEqual(data1, 'abc');
42 assert.strictEqual(data2, 'abc');
43}
44
45function testShareSyncCancel() {
46 // Verify that cancel() on a pre-iteration share yields nothing

Callers 1

Calls 4

shareSyncFunction · 0.85
textSyncFunction · 0.85
genFunction · 0.70
pullMethod · 0.45

Tested by

no test coverage detected