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

lb-fetch

v1.1.0

Published

Load balanced fetch

Readme

lb-fetch

NPM Version

A load balanced fetch.

Installation

npm i lb-fetch

Usage

import lbFetch from 'lb-fetch';

const response = await lbFetch(
  [
    "https://server1.example.com/api/endpoint",
    new URL("https://server2.example.com/api/endpoint")
  ],
  {
    method: 'POST',
    body: new URLSearchParams({
      foo: 'bar',
      baz: '42'
    })
  }
);

API

lbFetch(input, init?, options?)

Tries to fetch one of the inputs in some order until successful.

Returns a Promise of a Response.

input

Type: (string | URL)[] or generic InputType[]

The URLs to try. The input may also be an array of anything else, then options.balancer must be defined.

init

Type: RequestInit | undefined

Default: undefined

Same as fetch options.

options.fetch

Type: typeof fetch

Default: the global fetch method

Any method that conforms to the Fetch API.

options.balancer

Type: Balancer<InputType = string | URL>

type Balancer<InputType = string | URL> = (
  inputs: InputType[],
  init: RequestInit | undefined
) => Promise<(string | URL)[]> | (string | URL)[];

Default: randomBalancer

This method decides the order in which the entries of input are tried.

Note: the default value only works for inputs consisting of strings and URLs.

options.success

Type: SuccessPredicate

type SuccessPredicate = (response: Response) => boolean;

Default: reject500s

This method decides whether an attempt was successful.

If a request to an input throws an exception, it is also considered unsuccessful.

randomBalancer(input)

The default balancer returns a shuffled shallow copy of its input.

input

Type: (string | URL)[]

reject500s(response)

The default SuccessPredicate accepts a response, if its status is less than 500 – i.e. if the response was not a server error.