New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

setinterval-bykey

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

setinterval-bykey

A simple Node.js utility to manage multiple named intervals easily.

latest
Source
npmnpm
Version
1.0.3
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Interval Manager

  • A lightweight and easy-to-use Node.js utility to manage multiple named intervals.

Features

  • Start multiple intervals identified by unique keys.
  • Check if a specific interval is running by its key.
  • Clear individual intervals or all intervals at once.
  • Throws clear errors on invalid input.
  • Minimal dependencies, pure Node.js timer management.

Installation

npm install setinterval-bykey

Usage

const intervalManager = require('interval-manager');

// Start an interval that logs "Hello" every second
intervalManager.start(() => {
  console.log('Hello');
}, 1000, 'greeting');

// Check if 'greeting' interval is running
console.log(intervalManager.isRunning('greeting')); // true

// Stop the 'greeting' interval after 5 seconds
setTimeout(() => {
  intervalManager.clear('greeting');
  console.log('Greeting interval stopped');
}, 5000);

API

start(fn, interval, key)

Starts a new interval with the callback function fn running every interval milliseconds under the identifier key.

Throws TypeError if parameters are invalid.

Returns true if interval started successfully, or false if an interval with the same key already exists.

isRunning(key)

Checks if an interval under the given key is currently active.

Throws TypeError if key is invalid.

Returns true if running, otherwise false.

clear(key)

Stops and removes the interval identified by key.

Throws TypeError if key is invalid.

Returns true if interval was cleared, or false if no interval found under that key.

clearAll()

Stops and clears all running intervals.

📜 License

MIT

✍️ Author

Youssef Mohamed - (SLASH)

  • npm
  • GitHub
  • Discord

Feel free to open issues or contribute! 🚧

Keywords

interval

FAQs

Package last updated on 25 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts