/SetIntervalJS

⏰ start and clear interval without setting a variable

Primary LanguageJavaScriptMIT LicenseMIT

SetIntervalJS Twitter URL

MIT Licence Gemnasium Build Status npm version

SetIntervalJS is a constructor which hide inside reference to setInterval() for cleaner usage. It helps to make your code cleaner and there is no need to have more variables for clearInterval() 👌. SetIntervalJS has two methods start and clear. start method calls a function at specified intervals (in milliseconds) and clear clear the interval.

Getting SetIntervalJS

npm

npm install --save set-interval

yarn

yarn add set-interval --save

Examples

SetInterval.start(function, milliseconds)

Basic example

import SetInterval from 'set-interval'

SetInterval.start(callback, 1000)
SetInterval.clear()

Multiple instances

import SetInterval from 'set-interval'

const SetInterval_2 = Object.assign({}, SetInterval)
const SetInterval_3 = Object.assign({}, SetInterval)

SetInterval.start(callback, 1000)
SetInterval_2.start(callback_2, 1000)
SetInterval_3.start(callback_3, 1000)

SetInterval.clear()
SetInterval_2.clear()
SetInterval_3.clear()

Contributing

Any contributions you make are greatly appreciated.

Please read the Contributions Guidelines before submitting a PR.

License

MIT © Vasyl Stokolosa