ndjson-web
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

ndjson-web

Build JavaScript Style Guide

NDJSON parser + serializer using web streams. Zero dependencies.

Install

npm i ndjson-web

Usage

Parse

import { Parse } from 'ndjson-web'

readable
  .pipeThrough(new Parse())
  .pipeTo(new WritableStream({
    write (obj) {
      console.log(obj)
    }
  }))

Serialize

import { Stringify } from 'ndjson-web'

const items = [{ one: 1 }, { two: 2 }, { three: 3 }]
new ReadableStream({
  pull (controller) {
    const item = items.shift()
    return item ? controller.enqueue(item) : controller.close()
  }
}).pipeThrough(new Stringify()).pipeTo(writable)

Contributing

Feel free to join in. All welcome. Please open an issue!

License

Dual-licensed under MIT + Apache 2.0

/ndjson-web/

    Package Sidebar

    Install

    npm i ndjson-web

    Weekly Downloads

    9

    Version

    1.1.0

    License

    Apache-2.0 OR MIT

    Unpacked Size

    16.8 kB

    Total Files

    5

    Last publish

    Collaborators

    • alanshaw