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 🙏

© 2025 – Pkg Stats / Ryan Hefner

waitify

v2.0.1

Published

A flexible and feature-rich delay utility for JavaScript with pause/resume, progress tracking, retry, and more.

Downloads

58,468

Readme

Enhanced Delay (Waitify)

A flexible and feature-rich delay utility for JavaScript that goes beyond a simple timeout.

Features

  • Basic delay - Simple promise-based delay
  • Callback support - Execute a function after the delay
  • Jitter - Add random variance to delay times
  • Progress tracking - Monitor delay progress
  • Pause/Resume - Pause and resume delays
  • Timeout protection - Set maximum wait time
  • Retry logic - Automatically retry with configurable backoff
  • Cancellation - Cancel pending delays

Installation

npm install waitify

Usage

Basic Delay

const delay = require('waitify');

// Simple delay
const { promise } = delay(1000);
await promise; // Waits for 1 second

With Callback

// With callback
delay(1000, () => {
  console.log('1 second has passed!');
});

// Or using object syntax
delay(1000, {
  callback: () => console.log('1 second has passed!')
});

Progress Tracking

delay(5000, {
  onProgress: (percentage) => {
    console.log(`Progress: ${percentage}%`);
  }
});

Jitter

Add random variance to avoid thundering herd problems in distributed systems:

// 10% jitter (900-1100ms)
delay(1000, {
  jitter: 0.1
});

Pause and Resume

const delayObj = delay(10000);

// Later...
const remainingTime = delayObj.pause();
console.log(`Paused with ${remainingTime}ms remaining`);

// Resume when needed
delayObj.resume();

Retry Logic

delay(1000, {
  callback: () => {
    // This will retry if it throws an error
    makeApiCall();
  },
  maxRetries: 3,
  retryDelay: 500,
  exponentialBackoff: true,
  onRetry: (retryCount) => {
    console.log(`Attempt ${retryCount} failed, retrying...`);
  }
});

Timeout Protection

try {
  await delay(5000, {
    timeout: 2000
  }).promise;
} catch (error) {
  console.error('Delay timed out');
}

Cancellation

const { promise, cancel } = delay(10000);

// Later...
cancel();

API Reference

delay(ms, options)

Returns a DelayResult object with the following properties:

  • promise - Promise that resolves when the delay completes
  • cancel() - Function to cancel the delay
  • pause() - Pause the delay and return remaining time
  • resume() - Resume a paused delay
  • retryCount - Number of retry attempts (if retries enabled)
  • elapsedTime - Total elapsed time in milliseconds
  • isRunning - Whether the delay is currently running

Options

  • callback - Function to call after delay
  • jitter - Random variance factor (0-1)
  • maxRetries - Maximum retry attempts
  • retryDelay - Delay between retries
  • exponentialBackoff - Whether to use exponential backoff for retries
  • timeout - Maximum time to wait (0 = no timeout)
  • onProgress - Progress callback (receives percentage 0-100)
  • onRetry - Called when a retry occurs (receives retry count)

License

Unlicense: Free to do anything with it, IDGAF!