Nanotechnology Promises Much

    response-iterator
    TypeScript icon, indicating that this package has built-in type declarations

    0.2.6 • Public • Published

    response-iterator

    Creates an async iterator for a variety of inputs in the browser and node. Supports fetch, node-fetch, cross-fetch, axios, got, undici.

    Example 1

    // import "isomorphic-fetch"; // node only
    import responseIterator from 'response-iterator';
    
    const res = await fetch('https://raw.githubusercontent.com/kmalakoff/response-iterator/master/package.json');
    
    let data = '';
    for await (const chunk of responseIterator(res)) {
      data += chunk;
    }
    console.log(JSON.parse(data).name); // "response-iterator"

    Example 2

    import crossFetch from 'cross-fetch';
    import responseIterator from 'response-iterator';
    
    const res = await crossFetch('https://raw.githubusercontent.com/kmalakoff/response-iterator/master/package.json');
    
    let data = '';
    for await (const chunk of responseIterator(res)) {
      data += chunk;
    }
    console.log(JSON.parse(data).name); // "response-iterator"

    Documentation

    API Docs

    Install

    npm i response-iterator

    DownloadsWeekly Downloads

    761,196

    Version

    0.2.6

    License

    MIT

    Unpacked Size

    67.8 kB

    Total Files

    35

    Last publish

    Collaborators

    • kmalakoff