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

fetch-extras

v3.1.0

Published

Useful utilities for working with Fetch

Downloads

74,718

Readme

Useful utilities for working with Fetch

Build tiny, focused HTTP clients by composing only the features you need on top of the standard fetch API. No wrapper objects, no new interface to learn, no lock-in.

Highlights

  • Composable — Each with* function adds a single capability. Stack them to build exactly the client you need.
  • Works everywhere — Browsers, Node.js, Deno, Bun, Cloudflare Workers, etc.
  • Zero dependencies
  • Standard fetch — The input and output are always a plain fetch function. Your code stays portable and familiar.
  • Tree-shakeable — Only the utilities you import end up in your bundle.
  • TypeScript — Full type definitions with strong generics.
  • Schema validation — Validate responses against Standard Schema (Zod, Valibot, ArkType, etc.).

For a full-featured HTTP client on top of Fetch, check out my ky package.

Install

npm install fetch-extras

Usage

import {
	pipeline,
	withTimeout,
	withBaseUrl,
	withHeaders,
	withHttpError,
	withJsonResponse,
} from 'fetch-extras';

// Create a tiny reusable API client that:
// - Times out after 5 seconds
// - Uses a base URL so you only write paths
// - Sends auth headers on every request
// - Throws errors for non-2xx responses
// - Parses JSON responses automatically
const apiFetch = pipeline(
	fetch,
	withTimeout(5000),
	withBaseUrl('https://api.example.com'),
	withHeaders({Authorization: 'Bearer token'}),
	withHttpError(),
	withJsonResponse(),
);

const data = await apiFetch('/users');

pipeline() order is the documented order throughout this package. Runtime wrapper nesting is the inverse, so pipeline(fetch, withTimeout(5000), withHeaders(headers)) becomes withHeaders(headers)(withTimeout(5000)(fetch)).

API

Wrappers

Listed in the recommended pipeline order. Read the list top to bottom as the order you pass wrappers to pipeline().

Choose one terminal response wrapper:

Utilities

Errors

FAQ

How is this different from Ky?

Ky is a full-featured HTTP client with its own API (ky.get(), .json(), etc.). This package instead gives you individual utilities that wrap the standard fetch function. You pick only what you need and compose them together. If you want a batteries-included client, use Ky. If you want to stay close to the fetch API while adding specific capabilities, use this.

How do I use a proxy?

This package wraps the standard fetch API, so proxy support comes from the runtime. In Node.js, use the --use-env-proxy flag.

Related

  • is-network-error - Check if a value is a Fetch network error
  • ky - HTTP client based on Fetch
  • parse-sse - Parse Server-Sent Events (SSE) from a Response