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

unlimited-timeout

v0.1.0

Published

setTimeout and setInterval that work with delays longer than 24.8 days

Readme

unlimited-timeout

setTimeout and setInterval that work with delays longer than 24.8 days

JavaScript's built-in setTimeout and setInterval have a maximum delay of 2^31-1 milliseconds (approximately 24.8 days). Attempting to use a longer delay causes the timer fires immediately with a 1ms delay instead of waiting for the intended duration.

This package provides drop-in replacements that handle arbitrarily long delays by automatically breaking them into smaller chunks.

Install

npm install unlimited-timeout

Usage

import {setTimeout, clearTimeout} from 'unlimited-timeout';

// Schedule a callback for 30 days in the future
// With native setTimeout, this would fire immediately and show a warning in Node.js
const timeout = setTimeout(() => {
	console.log('30 days have passed!');
}, 30 * 24 * 60 * 60 * 1000);

// Cancel it if needed
clearTimeout(timeout);
import {setInterval, clearInterval} from 'unlimited-timeout';

// Call a function every 30 days
const interval = setInterval(() => {
	console.log('Another 30 days have passed!');
	// Do monthly cleanup, send reports, etc.
}, 30 * 24 * 60 * 60 * 1000);

// Stop it later
clearInterval(interval);

Notes

  • The timeout/interval objects returned by this package are not interchangeable with native timeout IDs.
  • You must use the clearTimeout/clearInterval functions from this package, not the native ones.
  • For delays under ~24.8 days, this package adds minimal overhead as it doesn't need to chunk.
  • This package works in both Node.js and browsers.

API

setTimeout(callback, delay, ...arguments)

Schedule a function to be called after a delay, even if the delay exceeds JavaScript's built-in setTimeout maximum of ~24.8 days.

Unlike the native setTimeout, this function handles arbitrarily long delays by breaking them into smaller chunks internally.

Returns a Timeout object that can be passed to clearTimeout().

callback

Type: Function

The function to call after the delay.

delay

Type: number (any value will be coerced to number)
Default: 0

The delay in milliseconds. Like native setTimeout, the value is coerced to a number. Invalid values (NaN, negative numbers) are clamped to 0 (immediate firing). Infinity means wait forever (never fire).

arguments

Type: any[]

Optional arguments to pass to the callback.

import {setTimeout} from 'unlimited-timeout';

// Pass arguments to the callback
setTimeout((name, count) => {
	console.log(`Hello ${name}, called ${count} times`);
}, 1000, 'Alice', 42);

clearTimeout(timeout)

Cancel a timeout created with setTimeout().

This function is safe to call multiple times with the same timeout object, and it's safe to call with undefined or null.

timeout

Type: Timeout | undefined | null

The timeout object to cancel.

setInterval(callback, delay, ...arguments)

Schedule a function to be called repeatedly with a delay between each call, even if the delay exceeds JavaScript's built-in setInterval maximum of ~24.8 days.

Unlike the native setInterval, this function handles arbitrarily long delays by breaking them into smaller chunks internally.

Returns a Timeout object that can be passed to clearInterval().

callback

Type: Function

The function to call after each delay.

delay

Type: number (any value will be coerced to number)
Default: 0

The delay in milliseconds between each call. Like native setInterval, the value is coerced to a number. Invalid values (NaN, negative numbers) are clamped to 0 (immediate firing). Infinity means wait forever (never fire).

arguments

Type: any[]

Optional arguments to pass to the callback.

clearInterval(interval)

Cancel an interval created with setInterval().

This function is safe to call multiple times with the same interval object, and it's safe to call with undefined or null.

interval

Type: Timeout | undefined | null

The interval object to cancel.

MAX_TIMEOUT

Type: number
Value: 2_147_483_647

Maximum safe timeout value for setTimeout in JavaScript (2^31-1 milliseconds). This is approximately 24.8 days.

Related

  • delay - Delay a promise a specified amount of time