A PassThrough stream that stops piping when a pattern is reached
Ever wanted to pause a stream when a certain String or a binary signature is reached? UntilStream is the answer. Pipe UntilStream and automatically stop when your pattern is reached or call read() until the returned data matches your pattern, without excessively buffering your stream's content in memory.
|Stability - API is somewhat unstable|
$ npm install until-stream
var UntilStream = ;var streamBuffers = ;var us = pattern: 'World';var sourceStream = ;sourceStream;var writableStream = ;sourceStream;writableStream;
var UntilStream = ;var streamBuffers = ;var us = pattern: 'jumps';var sourceStream = chunkSize: 8 ;sourceStream;sourceStream;us;
UntilStream also includes stream.Readable and stream.Writable methods. See the node v0.9 [Stream documentation] (http://nodejs.org/docs/v0.9.10/api/stream.html) for more.## UntilStream ### new UntilStream([options])
Synchronously consume data from UntilStream's internal buffer. If the specified pattern is detected within the current chunk, slice off the portion prior to the pattern. The next call to read() will return exactly the pattern. Otherwise return the current chunk.
Buffer | null
var us = pattern: '\n' ;us;var hello = us;console;us; //matches '\n' pattern!var world = us;console;
Pipe incoming data from UntilStream to the destination WriteStream. If the pattern is reached, leave the pattern on the internal buffer, disconnect the pipe, and call end() on the destination. Back-pressure is properly managed.
Stream - the destination stream
var us = pattern: '\n' ;var loremIpsumStream = fs;var outputStream = fs;loremIpsumStream;
Reconfigure the pattern option. It's unwise to call this method while piping to a destination stream.
var us = ;us;us;var hello = us;console;us; //matches '\n' pattern!var world = us;console;