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

set-interval-manager

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

set-interval-manager

A utility class for managing intervals created by setInterval

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

set-interval-manager

npm version GitHub license

A utility class for managing intervals created by setInterval.

Installation

You can install the package using npm:

npm install set-interval-manager

Examples

// ES6 import
import SetInterval from 'set-interval-manager';

// (or) CommonJS require
const SetInterval = require('set-interval-manager');


const mockFn = () => 'set-interval-manager';

// --- (start + clear) ---

SetInterval.start(mockFn, 1000, 'basic-example');

SetInterval.clear('basic-example');

// --- (start + clearAll) ---

SetInterval.start(mockFn, 1000, 'interval-one');
SetInterval.start(mockFn, 1500, 'interval-two');
SetInterval.start(mockFn, 2000, 'interval-three');

SetInterval.clearAll();

// --- (start + listAll) ---

SetInterval.start(mockFn, 1000, 'interval-one');
SetInterval.start(mockFn, 1500, 'interval-two');

SetInterval.listAll(); // => ['interval-one', 'interval-two']

SetInterval.clear('interval-one');

SetInterval.listAll(); // => ['interval-two']

API

SetInterval

The main class exported by the package.

start(fn: IntervalFn, interval: number, key: string): void

Starts a new interval that calls the specified function at the specified interval.

  • fn (required): The function to call.
  • interval (required): The interval (in milliseconds) at which to call the function.
  • key (required): A unique string identifier for the interval.

clear(key: string): void

Stops the interval with the specified key.

  • key (required): The string identifier for the interval to stop.

clearAll(): void

Stops all intervals managed by this utility.

listAll(): string[]

Gets an array of all keys currently being used to manage intervals.

License

This package is released under the MIT License.

Keywords

setInterval

FAQs

Package last updated on 29 Apr 2023

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