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

1.1.7 • Public • Published

fetch-ndjson

fetch-ndjson turns new line delimited JSON streaming responses retrieved using Fetch API into Generators that yield JSON.

Install

npm i fetch-ndjson

Usage

import ndjson from 'fetch-ndjson';

let res = await fetch(pathname);
let reader = res.body.getReader();
let gen = ndjson(reader);
while (true) {
  let { done, value } = await gen.next();
  console.log(`done=${done}, value=${JSON.stringify(value)}`);
  if (done) {
    return;
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i fetch-ndjson

Weekly Downloads

835

Version

1.1.7

License

MIT

Unpacked Size

25.6 kB

Total Files

17

Last publish

Collaborators

  • mash