user3305221
user3305221

Reputation: 31

Nodejs Readable Stream push usage

I run some code in command with node; It's on error when the code like this:

> var rs = new require('stream').Readable();
> rs.push("123");rs.push(null); // two pushes are in the same row;

but this is error:

> var rs = new require('stream').Readable();
> rs.push("123");  // I went them are not in the same row;
// then get a error, like :
events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: not implemented
    at Readable._read (_stream_readable.js:446:22)
    at Readable.read (_stream_readable.js:320:10)
    at maybeReadMore_ (_stream_readable.js:431:12)
    at _stream_readable.js:422:7
    at process._tickCallback (node.js:415:13)

I need code like this:

var rs = new require('stream').Readable();
rs.pipe(someWriteAbleStream)
// some time later
rs.push(somedata);
// some time late
rs.push(somedata);
// ...
rs.push(null);

Thanks;

Upvotes: 3

Views: 4355

Answers (1)

user2434831
user2434831

Reputation: 63

because , if you no rs.push(null), then cache is null, so rs call ._read() to read.

if rs.push(null) , mean is done.

Upvotes: 3

Related Questions