# jstream

> Continously reads in JSON and outputs Javascript objects.

Latest version **1.1.1** (published 2018-03-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install jstream
pnpm add jstream
yarn add jstream
bun add jstream
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2018-03-23 |
| First published | 2012-06-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4 |
| Dependencies | 1 |
| Unpacked size | 7.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 19 |
| Author | fent |
| Maintainers | fent |
| Keywords | stream, json, parse, api |

## Links

- npm: https://www.npmjs.com/package/jstream
- Repository: https://github.com/fent/node-jstream
- Homepage: https://github.com/fent/node-jstream#readme
- Issues: https://github.com/fent/node-jstream/issues
- npm.io page: https://npm.io/package/jstream

## Dependencies (1)

- [clarinet](https://npm.io/package/clarinet.md) ~0.12.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.1.1 (latest) — 2018-03-23
- 1.1.0 — 2017-10-22
- 1.0.1 — 2017-08-10
- 1.0.0 — 2017-03-01
- 0.2.11 — 2016-12-05
- 0.2.10 — 2016-07-24
- 0.2.9 — 2016-02-07
- 0.2.8 — 2015-09-27
- 0.2.7 — 2014-03-13
- 0.2.6 — 2014-03-10
- 0.2.5 — 2014-03-01
- 0.2.4 — 2013-03-19
- 0.2.3 — 2013-03-13
- 0.2.2 — 2012-12-01
- 0.2.1 — 2012-12-01
- … 2 more at https://npm.io/package/jstream/versions

## README

# 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](https://secure.travis-ci.org/fent/node-jstream.svg)](http://travis-ci.org/fent/node-jstream)
[![Dependency Status](https://david-dm.org/fent/node-jstream.svg)](https://david-dm.org/fent/node-jstream)
[![codecov](https://codecov.io/gh/fent/node-jstream/branch/master/graph/badge.svg)](https://codecov.io/gh/fent/node-jstream)

# Usage

```js
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

```js
{ "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](https://mochajs.org)

```bash
npm test
```

---
_Source: https://npm.io/package/jstream · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
