1.0.1 • Published 3 months ago

it-ndjson-stream v1.0.1

Weekly downloads
-
License
Apache-2.0 OR MIT
Repository
github
Last release
3 months ago

it-ndjson-stream

codecov CI

Read and write ndjson messages over a duplex stream

About

This module makes it easy to send and receive ndjson messages over streams.

Example

import { ndjsonStream } from 'it-ndjson-stream'

const stream = ndjsonStream(duplex)

// read the next message
const obj = await stream.read()

// write a message
await stream.write({ hello: 'world' })

// write several messages
await stream.writeV([
  { hello: 'world' },
  { how: 'are you' }
])

Install

$ npm i it-ndjson-stream

Browser <script> tag

Loading this module through a script tag will make its exports available as ItLengthPrefixedStream in the global namespace.

<script src="https://unpkg.com/it-ndjson-stream/dist/index.min.js"></script>

API Docs

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

1.0.1

3 months ago

1.0.0

6 months ago

0.0.0

6 months ago