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

async-retry-wrapper

v1.0.1

Published

Wrap the async function

Readme

async-retry-wrapper

Documentation

Retry wrapper for async function.

Installation

$ npm install async-retry-wrapper

Javascript

const retryWrapper = require('async-retry-wrapper');

Typescript

import * as retryWrapper from 'async-retry-wrapper';

Usage

functions

An object consisting of an async function may be used. If it is not an async function, an error occurs.

const retryWrapper = require('async-retry-wrapper');

const functions = {
    logger: async () => {
        console.log('hello world!!');
    },
};

const wrappedFunctions = retryWrapper(functions);

option

You can also change the retry settings if you want(If there is no parameter, it operates as Default).

There are a total of three options.

  • options
    • count : How many times are you going to try again?
      • default: 1
    • interval: How often will you try again?, 0 means as quickly as possible.
      • default: 0 (milliseconds)
    • rule: When are you gonna stop trying again?, Only one parameter is error.
      • default: Retry if an error occurs
    • logging: Do I need a log for retries?
      • default: false

The example is an option to retry twice more at 100 ms intervals when the response status is not 500.

const retryWrapper = require('async-retry-wrapper');

const options = {
    count: 2,
    interval: 100, 
    // If the response status code is not 500, the retry will be stopped
    rule: err => err.status !== 500,
    logging: true,
};

const wrappedFunctions = retryWrapper(someFunObject, options);

Demo

// import library
const retryWrapper = require('async-retry-wrapper');

// test object to be wrapped
const testFunctions = {
    logAndThrow: async () => {
        console.log('welcome');
        throw new Error('with occur error!');
    },
    log: async () => {
        console.log('hello world!');
    },
};

// wrapping object
const wrappedFunctions = retryWrapper(testFunctions);

// now you can see the function retries
wrappedFunctions['logAndThrow']();

License

MIT License