peek-stream
Transform stream that lets you peek the first line before deciding how to parse it
npm install peek-stream
Usage
var peek =var ldjson =var csv =var {return data > -1}var {tryJSONreturn truecatch errreturn false}// call parser to create a new parservar {return}
The above parser will be able to parse both line delimited JSON and CSV
var parse =parseparse
Or
var parse =parseparse
Per default data
is the first line (or the first 65535
bytes if no newline is found).
To change the max buffer pass an options map to the constructor
var parse =
If you want to emit an error if no newline is found set strict: true
as well.
License
MIT