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

sentra

v1.0.2

Published

Async retry with exponential backoff for Node.js and browsers.

Readme

sentra

Async retry with configurable backoff for Node.js and browsers. Retries on thrown or rejected errors; supports per-attempt timeout, optional jitter, circuit breaker, and cancellation via AbortSignal.

npm version License: MIT Node.js version

Table of Contents

Installation

npm install sentra

Usage

import { retry } from "sentra";

const data = await retry(
  async () => {
    const res = await fetch("https://api.example.com/data");
    if (!res.ok) throw new Error(res.statusText);
    return res.json();
  },
  { retries: 5, delay: 200, factor: 2 }
);

Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | retries | number | 3 | Number of retries after the first attempt. | | delay | number | (attempt: number) => number | 100 | Initial delay in ms, or function for custom delay per attempt. | | maxDelay | number | — | Maximum delay between attempts (caps exponential backoff). | | factor | number | 2 | Multiplier for delay after each attempt. | | jitter | boolean | "full" | "equal" | — | Add randomness: true/"full" = 0..delay, "equal" = delay/2..delay. | | timeout | number | — | Per-attempt timeout in ms. | | maxDuration | number | — | Stop retrying after this many ms from the start. | | signal | AbortSignal | — | Abort retries when signal is aborted. | | retryOn | (error, attempt) => boolean | Promise<boolean> | — | Predicate to decide whether to retry; if false, last error is thrown. | | onRetry | (error, attempt, nextDelay) => void | — | Called before each wait. | | circuitBreaker | object | — | { failureThreshold, cooldown, state } to fail fast after N failures until cooldown. |

After all attempts are used (or maxDuration / retryOn stops retries), the last error is rethrown with a wrapper that includes attempt count and elapsed time as cause.

AbortSignal

Pass an AbortSignal to cancel retries when the user navigates away or a parent operation is cancelled.

import { retry } from "sentra";

const controller = new AbortController();

const result = await retry(
  async () => fetch("https://api.example.com/data").then((r) => r.json()),
  { retries: 10, delay: 1000, signal: controller.signal }
);

// Later: controller.abort() rejects with DOMException "AbortError"

API

The package exports:

  • retry<T>(fn, options?) — Runs the async function with retries. Returns a Promise that resolves with the function’s result or rejects with the last error (with attempt info on cause).

TypeScript types are included.

Requirements

  • Node.js: >= 18 (see engines)
  • Browsers: Any environment that supports Promise, AbortSignal, and ES modules.

Contributing

Contributions are welcome. Please open an issue or pull request on GitHub.

Security

To report a security vulnerability, please open a GitHub Security Advisory or contact the maintainers responsibly. Do not open public issues for security-sensitive topics.

License

MIT License. You may use, copy, modify, and distribute this software under the terms of the MIT License. See the LICENSE file in the repository for the full text.