/ never-odd-or-even / back / node_modules / reinterval /

[ICO]NameLast modifiedSizeDescription
[PARENTDIR]Parent Directory  -  
[DIR]tests/2 years ago -  
[   ]LICENSE9 years ago1.1K 
[TXT]README.md9 years ago2.1K 
[   ]index.js9 years ago1.3K 
[   ]package.json2 years ago1.5K 
README.md

reInterval

TRAVIS

NPM

Reschedulable setInterval for node.js.

Note: Work highly inspired by mcollina's retimer.

Example

var reInterval = require('reInterval');

var inter = reInterval(function () {
  console.log('this should be called after 13s');
}, 10 * 1000);

// This will reset/reschedule the interval after 3 seconds, therefore
// the interval callback won't be called for at least 13 seconds.
setTimeout(function () {
  inter.reschedule(10 * 1000);
}, 3 * 1000);

API:

###reInterval(callback, interval[, param1, param2, ...])

This is exactly like setInterval.

Arguments:

####returns an interval object with the following methods:

###interval.reschedule([interval])

This function resets the interval and restarts it now.

Arguments:

###interval.clear()

This function clears the interval. Can be used to temporarily clear the interval, which can be rescheduled at a later time.

###interval.destroy()

This function clears the interval, and will also clear the callback and params passed to reInterval, so calling this essentially just makes this object ready for overwriting with a new interval object.

Note:

Please ensure that either the interval.clear() or interval.destroy() function is called before overwriting the interval object, because the internal interval can continue to run in the background unless cleared.

license

MIT

Apache/2.4.38 (Debian) Server at www.karls.computer Port 80