Nondeterministic Polynomial Munchies

    concatjson
    DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/concatjson package

    2.0.1 • Public • Published

    concatjson

    npm travis

    Standard JavaScript

    Inspired by https://github.com/maxogden/ndjson

    concatjson is concatenated JSON streaming parser/serializer for Node.js.

    Install

    npm i concatjson

    Usage

    concatjson.parse()

    parses concatenated JSON stream and emits javascript objects.

    somefile (contains concatenated JSON objects)

    {"foo":"bar"}{"qux":"corge"}{"baz":{"waldo":"thud"}}
    const fs = require('fs')
    const cj = require('concatjson')
     
    fs.createReadStream('./somefile')
      .pipe(cj.parse())
      .on('error', err => console.error(err))
      .on('data', obj => {
        // obj is a js object
      })

    concatjson.serialize()

    alias: concatjson.stringify()

    accepts objects and emits stringified JSON objects.

    const cj = require('concatjson')
    const ser = cj.serialize()
    ser.write({foo: 'bar'})
    ser.end()
    ser.on('data', dat => {
      // dat is stringified JSON
    })

    License

    MIT

    Install

    npm i concatjson

    DownloadsWeekly Downloads

    187

    Version

    2.0.1

    License

    MIT

    Last publish

    Collaborators

    • manidlou