Registry / devops / interval-queue

interval-queue

JSON →
library1.0.4jsnpmunverified

interval-queue is a lightweight Node.js utility library (v1.0.4) for managing periodic task execution. It provides a simple API to create, delete, and clear intervals with time units in milliseconds, seconds, minutes, or hours. Unlike raw setInterval, it offers centralized management and typed return values. Actively maintained with TypeScript types included. Suitable for scheduling repeated tasks in server-side applications.

npm install interval-queue
INSTALL
IMPORT
SIG · INTERVAL-QUEUE
I
interval-queue
devopsjavascriptv1.0.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

createInterval
import { createInterval } from 'interval-queue'
import createInterval from 'interval-queue'
This package uses named exports; default import is not available.
deleteInterval
import { deleteInterval } from 'interval-queue'
const { deleteInterval } = require('interval-queue')
Package is ESM-only; CommonJS require returns undefined.
createIntervalSecond
import { createIntervalSecond } from 'interval-queue'
Convenience function that takes seconds instead of milliseconds.
clearIntervals
import { clearIntervals } from 'interval-queue'
Stops all intervals managed by the package.

Creates a 2-second interval, deletes it after 10 seconds, and clears all intervals after 15 seconds.

import { createInterval, deleteInterval, clearIntervals } from 'interval-queue'; // Create an interval that runs every 2 seconds const interval = createInterval(() => { console.log('Task executed'); }, 2000); // Delete a specific interval after 10 seconds setTimeout(() => { deleteInterval(interval); console.log('Interval deleted'); }, 10000); // Clear all intervals after 15 seconds setTimeout(() => { clearIntervals(); console.log('All intervals cleared'); }, 15000);
Debug
Known issues
breakingThe package uses named exports only; default import or require() will fail.
fix
Use named imports like `import { createInterval } from 'interval-queue'`.
affects: >=1.0.0
gotchaIntervals are not automatically cleaned up when the process exits; you must call clearIntervals() to avoid hanging.
fix
Call clearIntervals() before process exit or in cleanup hooks (e.g., process.on('exit', clearIntervals)).
affects: >=1.0.0
gotchaThe deleteInterval function expects the return value of createInterval, not a number or string.
fix
Store the return value of createInterval and pass it to deleteInterval.
affects: >=1.0.0
deprecatedNo deprecation warnings in this version.
fix
N/A
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: createInterval is not a function
Default import used instead of named import.
fix
Replace `import createInterval from 'interval-queue'` with `import { createInterval } from 'interval-queue'`.
ReferenceError: deleteInterval is not defined
Using CommonJS require() which returns undefined for named exports.
fix
Change to ES module import or use destructuring: `const { deleteInterval } = require('interval-queue')` does not work; switch to `import { deleteInterval } from 'interval-queue'`.
Error: loop is not an interval object
Passing an invalid value (e.g., a number, string) to deleteInterval.
fix
Ensure you pass the exact object returned by createInterval (or createIntervalSecond, etc.).
Upgrade
Version history
1.0.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
interval-queue — npm install interval-queue · libregistry