response-iterator
Creates an async iterator for a variety of inputs in the browser and node. Supports fetch, node-fetch, and cross-fetch
Last updated 2 months ago by kmalakoff .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install response-iterator 
SYNC missed versions from official npm registry.

response-iterator

Create an async iterator for response bodies from Fetch, node-fetch, cross-fetch, Axios, or Node streams.

Install

npm install response-iterator

Use with fetch

import responseIterator from 'response-iterator';

const res = await fetch('https://raw.githubusercontent.com/kmalakoff/response-iterator/master/package.json');

const decoder = new TextDecoder();
let data = '';
for await (const chunk of responseIterator(res)) {
  data += typeof chunk === 'string' ? chunk : decoder.decode(chunk, { stream: true });
}
data += decoder.decode();
console.log(JSON.parse(data).name); // "response-iterator"

The example uses the global fetch available in modern Node.js and browsers. On older Node.js versions, pass a response from a fetch implementation such as cross-fetch. Yielded chunks keep the underlying body type, so decode Uint8Array chunks before treating them as text.

Documentation

API Docs

Current Tags

  • 1.0.14                                ...           latest (2 months ago)

42 Versions

  • 1.0.14                                ...           2 months ago
  • 1.0.13                                ...           2 months ago
  • 1.0.12                                ...           3 months ago
  • 1.0.11                                ...           6 months ago
  • 1.0.10                                ...           a year ago
  • 1.0.9                                ...           a year ago
  • 1.0.8                                ...           a year ago
  • 1.0.7                                ...           a year ago
  • 1.0.6                                ...           a year ago
  • 1.0.5                                ...           a year ago
  • 1.0.4                                ...           a year ago
  • 1.0.3                                ...           a year ago
  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
  • 0.2.25                                ...           a year ago
  • 0.2.24                                ...           a year ago
  • 0.2.23                                ...           a year ago
  • 0.2.22                                ...           2 years ago
  • 0.2.21                                ...           2 years ago
  • 0.2.20                                ...           2 years ago
  • 0.2.19                                ...           2 years ago
  • 0.2.18                                ...           2 years ago
  • 0.2.17                                ...           2 years ago
  • 0.2.16                                ...           2 years ago
  • 0.2.15                                ...           2 years ago
  • 0.2.14                                ...           2 years ago
  • 0.2.13                                ...           2 years ago
  • 0.2.11                                ...           2 years ago
  • 0.2.10                                ...           2 years ago
  • 0.2.9                                ...           2 years ago
  • 0.2.8                                ...           2 years ago
  • 0.2.7                                ...           2 years ago
  • 0.2.6                                ...           4 years ago
  • 0.2.5                                ...           4 years ago
  • 0.2.4                                ...           4 years ago
  • 0.2.3                                ...           4 years ago
  • 0.2.2                                ...           5 years ago
  • 0.2.1                                ...           5 years ago
  • 0.2.0                                ...           5 years ago
  • 0.1.1                                ...           5 years ago
  • 0.1.0                                ...           5 years ago
Maintainers (1)
Downloads
Total 117
Today 0
This Week 0
This Month 95
Last Day 0
Last Week 72
Last Month 22
Dependencies (0)
None
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE