Kevin 29b9a0c50c clean && clean html base %!s(int64=4) %!d(string=hai) anos
..
promise 29b9a0c50c clean && clean html base %!s(int64=4) %!d(string=hai) anos
promise_ 29b9a0c50c clean && clean html base %!s(int64=4) %!d(string=hai) anos
test 29b9a0c50c clean && clean html base %!s(int64=4) %!d(string=hai) anos
.editorconfig 29b9a0c50c clean && clean html base %!s(int64=4) %!d(string=hai) anos
CHANGELOG.md 29b9a0c50c clean && clean html base %!s(int64=4) %!d(string=hai) anos
CHANGES 29b9a0c50c clean && clean html base %!s(int64=4) %!d(string=hai) anos
LICENSE 29b9a0c50c clean && clean html base %!s(int64=4) %!d(string=hai) anos
README.md 29b9a0c50c clean && clean html base %!s(int64=4) %!d(string=hai) anos
delay.js 29b9a0c50c clean && clean html base %!s(int64=4) %!d(string=hai) anos
max-timeout.js 29b9a0c50c clean && clean html base %!s(int64=4) %!d(string=hai) anos
once.js 29b9a0c50c clean && clean html base %!s(int64=4) %!d(string=hai) anos
package.json 29b9a0c50c clean && clean html base %!s(int64=4) %!d(string=hai) anos
throttle.js 29b9a0c50c clean && clean html base %!s(int64=4) %!d(string=hai) anos
valid-timeout.js 29b9a0c50c clean && clean html base %!s(int64=4) %!d(string=hai) anos

README.md

Build status Windows status Transpilation status npm version

timers-ext

Timers extensions

Installation

$ npm install timers-ext

To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: Browserify, Webmake or Webpack

API

MAX*TIMEOUT *(timers-ext/max-timeout)_

Maximum possible timeout value in milliseconds. It equals to maximum positive value for 32bit signed integer, so 2³¹ (2147483647), which makes it around 24.9 days

delay(fn[, timeout]) (timers-ext/delay)

Returns function which when invoked will call fn function after specified timeout. If timeout is not provided nextTick propagation is used.

once(fn[, timeout]) (timers-ext/once)

Makes sure to execute fn function only once after a defined interval of time (debounce). If timeout is not provided nextTick propagation is used.

var nextTick = require("next-tick");
var logFoo = function() {
	console.log("foo");
};
var logFooOnce = require("timers-ext/once")(logFoo);

logFooOnce();
logFooOnce(); // ignored, logFoo will be logged only once
logFooOnce(); // ignored

nextTick(function() {
	logFooOnce(); // Invokes another log (as tick passed)
	logFooOnce(); // ignored
	logFooOnce(); // ignored
});

validTimeout(timeout) (timers-ext/valid-timeout)

Validates timeout value.
For NaN resolved timeout 0 is returned. If timeout resolves to a number:

  • for timeout < 0 0 is returned
  • for _0 >= timeout <= MAX_TIMEOUT_, timeout value is returned
  • for _timeout > MAX_TIMEOUT_ exception is thrown

Tests

$ npm test