set-interval

start and clear interval without setting a variable

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
set-interval
3352.1.33 years ago6 years agoMinified + gzip package size for set-interval in KB

Readme

SetIntervalJS Twitter URL%20%F0%9F%91%8C%F0%9F%98%80&twp=tweetbutton&url=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2Fset-interval&via=shystrukk) #
MIT Licence Build Status npm version Known Vulnerabilities
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() and you can clear interval anywhere you want👌.

Getting SetIntervalJS ##

npm

npm install --save set-interval

yarn

yarn add set-interval --save

Examples ##

SetInterval.start(function, milliseconds, key_string)

Basic example ###

import SetInterval from 'set-interval'

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

Multiple instances ###

// -> ./start.js
import SetInterval from 'set-interval'

SetInterval.start(callback, 1000, 'test')
SetInterval.start(callback_2, 1000, 'test_2')
SetInterval.start(callback_3, 1000, 'test_3')


// -> ./clear.js
import SetInterval from 'set-interval'

SetInterval.clear('test')
SetInterval.clear('test_2')
SetInterval.clear('test_3')

API ##

SetInterval.start(callback, milliseconds, keystring) ###

callback ####

Type: function
Function that gets called in each milliseconds interval

milliseconds ####

Type: number
Interval time in which callback function gets called

keystring ####

Type: string
Key name for which interval will be referenced

SetInterval.clear(keystring) ###

keystring ####

Type: string
Key name which was passed to .start method

Contributing

Any contributions you make are greatly appreciated.
Please read the Contributions Guidelines before submitting a PR.

License

MIT © Vasyl Stokolosa