easy-interval

1.1.0 • Public • Published

easy-interval

Intervals made easy

Install

$ npm install easy-interval

Example usage

With stopping outside of interval function:

const Interval = require('easy-interval');

const interval = new Interval(() => console.log('hello world'), 1000);

interval.start();

setTimeout(interval.stop, 5000); // or `interval.stop();`

With stopping inside of interval function:

const Interval = require('easy-interval');

const interval = new Interval(({stop}) => {
  console.log('hello world');
  if (status === 'complete') {
    stop();
  }
}, 1000);

interval.start();

API

Interval(fn, delay)

fn

Type: function

The function to set an interval on.

delay

Type: number

The time period in milliseconds.

Methods

Interval.start({stop})

stop

type: Function

Stops the interval.

Interval.stop()

License

MIT © jxom

Readme

Keywords

none

Package Sidebar

Install

npm i easy-interval

Weekly Downloads

1

Version

1.1.0

License

MIT

Unpacked Size

2.95 kB

Total Files

4

Last publish

Collaborators

  • jmoxey