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

Function test

test/parallel/test-stream-readable-no-unneeded-readable.js:5–31  ·  view source on GitHub ↗
(r)

Source from the content-addressed store, hash-verified

3const { Readable, PassThrough } = require('stream');
4
5function test(r) {
6 const wrapper = new Readable({
7 read: () => {
8 let data = r.read();
9
10 if (data) {
11 wrapper.push(data);
12 return;
13 }
14
15 r.once('readable', function() {
16 data = r.read();
17 if (data) {
18 wrapper.push(data);
19 }
20 // else: the end event should fire
21 });
22 },
23 });
24
25 r.once('end', function() {
26 wrapper.push(null);
27 });
28
29 wrapper.resume();
30 wrapper.once('end', common.mustCall());
31}
32
33{
34 const source = new Readable({

Calls 4

resumeMethod · 0.65
readMethod · 0.45
pushMethod · 0.45
onceMethod · 0.45

Tested by

no test coverage detected