1.1.0 • Published 6 years ago

easy-interval v1.1.0

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

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

1.1.0

6 years ago

1.0.0

6 years ago