Transform stream that encodes JSON data as multibuffers
Transform stream that encodes JSON data as multibuffers.
var jsonBuffStream = require'json-multibuffer-stream'var jsonEncoder = jsonBuffStreamfscreateReadStream'newline-delimited.json'pipejsonEncoderpipehttpPostToSomeServer
var encoder = jsonBuffStreamonRow// gets called on every row with the json data right before it gets encoded
you can also pass in a custom headers array to control how the resulting multibuffer is encoded
var headers = 'z' 'x' 'y'var encoder = jsonBuffStreamheadersencoderwritex: 1 y: 2 z: 3// multibuffer will be something like [3,2,1]
use a multibuffer-stream
.unpackStream() to decode the data on the other end