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 🙏

© 2026 – Pkg Stats / Ryan Hefner

snarfetch

v0.3.0

Published

A helpful fetch wrapper for NodeJS

Downloads

36

Readme

Snarfetch

May eventually be a helpful fetch wrapper/implementation that does things like caching and throttling.

Use

At its most basic:

import { fetch } from 'snarfetch';
await fetch('https://localhost');

The API exposed is the API provided by node-fetch and unless it's necessary to change it, what you pass in will be passed through.

The top-level fetch uses a default context and cache. If you want to change any of the options, or you want a separate cache, instantiate your own:

import { Snarfetch } from 'snarfetch';

const context = new Snarfetch({...});
await context.fetch('https://localhost');

Roadmap

  • [x] Wraps node-fetch.
  • [x] Throttles requests to servers that are struggling.
  • [x] Will avoid making requests in parallel when they may be deduplicated.
  • [x] Won't re-use a response that's expired.
  • [x] Will expire items from the cache.
  • [x] Will set an 'age' header on responses from the cache.
  • [ ] Will limit the size of object that will be cached.
  • [ ] Will pay attention to vary.
  • [ ] Will revalidate requests rather than retrying them.
  • [ ] Will pay attention to last-modified.
  • [ ] Will pay attention to etag.
  • [ ] Will store/suggest multiple versions returned with etag.
  • [ ] Will serve stale when allowed and unable to access the resource.
  • [ ] Will "pre-fresh" entries which are heavily used and due to expire soon, to prevent them from expiring.

Internals

A 'target' is a host/port combo. We throttle each target separately, and cache based on the path and query string within each target. This gives us a 'location'.

If we've not seen a location before, we'll only make one request until we get an indication of whether we can cache it or not. If we can't, we'll fire off any requests that might have been pending and won't wait next time. If we can, we'll read the entire body and return responses that stream from the cached Blob.

Once a cached location has expired, a subsequent request will zap the cache and start the process again. This is a fresh fetch, rather than a revalidation -- we discard the previous body.