3.0.0 • Published 11 years ago

json-multibuffer-stream v3.0.0

Weekly downloads
10
License
BSD-2-Clause
Repository
github
Last release
11 years ago

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

3.0.0

11 years ago

2.0.0

11 years ago

1.0.1

11 years ago

1.0.0

11 years ago

0.0.3

12 years ago

0.0.2

12 years ago

0.0.1

12 years ago