1.1.1 • Published 6 years ago

jstream v1.1.1

Weekly downloads
107
License
MIT
Repository
github
Last release
6 years ago

node-jstream

Continuously reads in JSON and outputs Javascript objects. Meant to be used with keep-alive connections that send back JSON on updates.

Build Status Dependency Status codecov

Usage

const JStream = require('jstream');
const request = require('request');

request('http://api.myhost.com/updates.json')
  .pipe(new JStream()).on('data', (obj) => {
    console.log('new js object');
    console.log(obj);
  });

API

new JStream(path)

Creates an instance of JStream. Inherits from Stream. Can be written to and emits data events with Javascript objects.

path can be an array of property names, RegExp's, booleans, and/or functions. Objects that match will be emitted in data events. Passing no path means emitting whole Javascript objects as they come in. For example, given the path ['results', true, 'id'] and the following JSON gets written into JStream

{ "results": [
  {"seq":99230
  ,"id":"newsemitter"
  ,"changes":[{"rev":"5-aca7782ab6beeaef30c36b888f817d2e"}]}
, {"seq":99235
  ,"id":"chain-tiny"
  ,"changes":[{"rev":"19-82224279a743d2744f10d52697cdaea9"}]}
, {"seq":99238
  ,"id":"Hanzi"
  ,"changes":[{"rev":"4-5ed20f975bd563ae5d1c8c1d574fe24c"}],"deleted":true}
] }

JStream will emit newsemitter, chain-tiny, and Hanzi in its data event.

JStream.MAX_BUFFER_LENGTH

Defaults to 64 * 1024.

Install

npm install jstream

Tests

Tests are written with mocha

npm test
1.1.1

6 years ago

1.1.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.2.11

7 years ago

0.2.10

8 years ago

0.2.9

8 years ago

0.2.8

9 years ago

0.2.7

10 years ago

0.2.6

10 years ago

0.2.5

10 years ago

0.2.4

11 years ago

0.2.3

11 years ago

0.2.2

11 years ago

0.2.1

11 years ago

0.2.0

12 years ago

0.1.0

12 years ago