This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

set-random-interval
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

setRandomInterval

setRandomInterval is an adaptation of JavaScript's native setInterval()function, allowing for both a minimum and maximum delay to be passed in, which is then used to invoke the callback at random intervals within the given range.

Purpose

There may be times where you'd like repetitive function calls to be executed on a more naturally-occurring timeline, as opposed to executing at fixed intervals. This is often the case when trying to emulate the real world in game development.

Installation

npm i set-random-interval

Usage

import setRandomInterval from 'set-random-interval';
 
// Pass in the callback, minimum delay (milliseconds), and maximum delay (milliseconds).
const interval = setRandomInterval(() => console.log('Hello World!'), 1000, 5000);
 
// Clear the interval if/when you'd like.
interval.clear();

Package Sidebar

Install

npm i set-random-interval

Weekly Downloads

5

Version

1.1.0

License

MIT

Unpacked Size

9.09 kB

Total Files

6

Last publish

Collaborators

  • npm