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

promise-enhancements

v1.0.8

Published

Enhances the prototype of promises to include more robust functionality

Downloads

2

Readme

Promise-Enhancements

This library enhances the Promise base class by adding many various additional functions: (with examples)

Installation

Standard npm install:

npm install promise-enhancements

API

Static functions

  • Promise.retry(fn, options):

    Retry function for repeated validation on Promise Other options: {times: 1, delay: 500, printErrors: false, errorPrefix: ''}

    async function worksFifthTime() {
        const c = window.count = (window.count || 0) + 1
        if (c > 4) return 'Yay'
        throw 'Nay'
    }
    Promise.retry(worksFifthTime, {retries: 2}) // Error: Nay, Nay
    Promise.retry(worksFifthTime, {retries: 8}) // Yay
  • Promise.firstSuccess(arr):

    Like Promise.map, but will yield at the first success. It will fail if all cases are rejections

    Promise.firstSuccess([
        Promise.reject(10),
        Promise.reject(20),
    ]) // = Error: 10, 20
    
    Promise.firstSuccess([
        Promise.reject(10),
        20,
        Promise.reject(30),
    ]) // = 20
  • Promise.sync(tasks)

    Runs an array of async functions in sequence (where the output of the previous callback is the input for the next)

    const increment = n => n+1
    const getServerCount = async domain => /* returns a number */
    
    Promise.sync(['domain.com', getServerCount, increment, increment])
    // Output: ['domain.com', 10, 11, 12]

Dynamic functions

  • <promise>.returns(value):

    Uses the value provided as the argument as the seed for the next step

    Promise.resolve(1)
        .then(add1)
        .returns(0)
        .then(add1) // = await add1(0) = 1
    // While all steps in the chain ran, the next element after return uses the new value
  • <promise>.sleep(value):

    Sleeps on current step in the chain

    Promise.resolve('//computername')
        .then(restartComputer)
        .return('//computername')
        .sleep(10e3) // 10s
        .then(checkIfOnline)
  • <promise>.print(value):

    Uses the value provided as the argument as the seed for the next step

    Promise.resolve(1)
        .print('Starting Chain with 1')
        .then(add1)
        .print(v => `New Value = ${v}`)       // Callback print syntax
        .print('Ending Chain', console.error) // Prints as an error
  • <promise>.map(value):

    Same usage as Array.map but on promises! Same as <promise>.then(arr => Promise.all(arr.map(callback)).

    Promise.resolve([1,2,3,4,5])
        .map(i => i**2)
        .map(fetchGithubUserByID) // Async task
        .map(i => i.user.image)
    
    // Fetches github profile images for Users: 1, 4, 9, 16, and 25
  • <promise>.sync(callback):

    Like <promise>.map but each task runs in sequence. Task = callback(input[task_index]) where task_index = 0..(input.length)

    Promise.resolve(['jon', 'ally', 'ap'])
        .sync(restartComputer)
    
    // Restart('jon'), if success only then restart('ally'), etc