npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ng-fetch

v1.0.5

Published

We start to implement ng-fetch (new generation - fetch), because the normal fetch api is not able to add missing features, for YEARS .... like upload, download progress ... and cancel requests. I want to have an lib that i can use in node and on the brows

Downloads

4

Readme

#ng-fetch

We start to implement ng-fetch (new generation - fetch), because the normal fetch api is not able to add missing features, for YEARS .... like upload, download progress ... and cancel requests. I want to have an lib that i can use in node and on the browser.

So we used polyfills:

Browser:

  • Buffer

Node

  • FormData / File

everything here is open-source :), be free to be part of it.

TODO: all features description TODO: add more examples

###Simple example (node and browser)

response object always has

status: http status code // negative codes if exception is raised

headers: response headers

response: response content as buffer

special if you use multipart/form-data

add specific polyfill for runtime

// for browser add node buffer to browser
import 'ng-fetch/browser';

// for node add browser formdata, file, blob to node
import 'ng-fetch/node';
import ngFetch from 'ng-fetch';

(async () => {
    const apiResponse = await ngFetch('http://api.plos.org/search?q=title:DNA');
    /*
     * Show response {
     * status: 200,
     * headers: {
     *   date: 'Sat, 01 May 2021 21:40:39 GMT',
     *   'content-type': 'application/json;charset=utf-8',
     *   'content-length': '19284',
     *   connection: 'close',
     *   'last-modified': 'Fri, 30 Apr 2021 22:20:02 GMT',
     *   etag: '"ZjljNjQwMDAwMDAwMDAwMFNvbHI="'
     * },
     * response: <Buffer 7b 0a 20 20 22 72 65 73 70 6f 6e 73 65 22 3a 7b 22 6e 75 6d 46 6f 75 6e 64 22 3a 35
     *   34 30 38 2c 22 73 74 61 72 74 22 3a 30 2c 22 6d 61 78 53 63 6f 72 ... 19234 more bytes>
     * }
     */
    console.log('Show response object', apiResponse);
    const content = JSON.parse(apiResponse.response.toString());

    /*
     * Show api response content {
     * response: {
     *   numFound: 5408,
     *   start: 0,
     *   maxScore: 6.5337167,
     *   docs: [
     *     [Object], [Object],
     *     [Object], [Object],
     *     [Object], [Object],
     *     [Object], [Object],
     *     [Object], [Object]
     *   ]
     *  }
     * }
     */
    console.log('Show api response content', content);
})();