Kévin Tessier 04fab6ba46 install gulp | 6 年之前 | |
---|---|---|
.. | ||
promise | 6 年之前 | |
promise_ | 6 年之前 | |
test | 6 年之前 | |
.editorconfig | 6 年之前 | |
CHANGELOG.md | 6 年之前 | |
CHANGES | 6 年之前 | |
LICENSE | 6 年之前 | |
README.md | 6 年之前 | |
delay.js | 6 年之前 | |
max-timeout.js | 6 年之前 | |
once.js | 6 年之前 | |
package.json | 6 年之前 | |
throttle.js | 6 年之前 | |
valid-timeout.js | 6 年之前 |
$ 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
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
Returns function which when invoked will call fn function after specified timeout. If timeout is not provided nextTick propagation is used.
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
});
Validates timeout value.
For NaN
resolved timeout 0
is returned.
If timeout resolves to a number:
0
is returnedtimeout
value is returned$ npm test