match-stream
Supply a function to handle pattern matches within a NodeJS stream.
Installation
$ npm install match-stream
Quick Examples
End stream on match
var MatchStream = ;var streamBuffers = ; var ms = pattern: 'World' { if !matched return this; this; return this; //signal end of data}; var sourceStream = ;sourceStream;var writableStream = ; sourceStream ; //Output//Piped data before pattern occurs: 'Hello '
Split stream
var MatchStream = ;var fs = ; var line = "";var loremLines = ;var ms = pattern: '.' consume: true { line += buf; if matched loremLines; line = ""; }; fs ;
License
MIT
Acknowledgements
Special thanks to @wanderview for assisting with the API.