/ moubarak.eu / node_modules / timers-ext /

[ICO]NameLast modifiedSizeDescription
[PARENTDIR]Parent Directory  -  
[DIR]promise/2 years ago -  
[DIR]promise_/2 years ago -  
[DIR]test/2 years ago -  
[TXT]CHANGELOG.md2 years ago1.4K 
[   ]CHANGES2 years ago577  
[   ]LICENSE2 years ago773  
[TXT]README.md2 years ago2.5K9b1f1b9 rm old utils [كارل مبارك]
[   ]delay.js2 years ago506  
[   ]max-timeout.js2 years ago 44  
[   ]once.js2 years ago1.0K 
[   ]package.json2 years ago886 2324c9f added npm start script [كارل مبارك]
[   ]throttle.js2 years ago727  
[   ]valid-timeout.js2 years ago288  
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:

Tests

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