json-multibuffer-stream

3.0.0 • Public • Published

json-multibuffer-stream

Transform stream that encodes JSON data as multibuffers.

NPM

usage

var jsonBuffStream = require('json-multibuffer-stream')
var jsonEncoder = jsonBuffStream()
fs.createReadStream('newline-delimited.json').pipe(jsonEncoder).pipe(httpPostToSomeServer)

optional arguments: jsonBuffStream(headers, onRow)

var encoder = jsonBuffStream(onRow)
 
function onRow(json) {
  // 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 = jsonBuffStream(headers)
encoder.write({x: 1, y: 2, z: 3})
// multibuffer will be something like [3,2,1]

you can write either JSON strings or JavaScript objects to the stream. JSON strings will get JSON.parse()'d

use a multibuffer-stream .unpackStream() to decode the data on the other end

Readme

Keywords

none

Package Sidebar

Install

npm i json-multibuffer-stream

Weekly Downloads

2

Version

3.0.0

License

BSD-2-Clause

Last publish

Collaborators

  • maxogden