Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

Is there a way to stop the stream? #146

Open
Ninjaman494 opened this issue Jan 5, 2018 · 2 comments
Open

Is there a way to stop the stream? #146

Ninjaman494 opened this issue Jan 5, 2018 · 2 comments

Comments

@Ninjaman494
Copy link

Is there a way to stop parsing after you hit a certain value?
For example:

 stream.on('data', function(data) {`
          if(data == 'someValue'){`
             stream.stop();
        }
    });

This would useful when you only need a certain value or you only need to check a specific number of entries.

@dominictarr
Copy link
Owner

no unfortunately node streams do not support that in a clean way. you could call source.destroy() but you'd have to call it on the real source, i.e. the file or the network connection.

@dominictarr
Copy link
Owner

this is why pull-streams have error propagation and abort: http://dominictarr.com/post/149248845122/pull-streams-pull-streams-are-a-very-simple

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants