Subtheme of barrio
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

21 lines
506 B

"use strict";
var callable = require("es5-ext/object/valid-callable")
, nextTick = require("next-tick")
, validTimeout = require("./valid-timeout");
var apply = Function.prototype.apply;
module.exports = function (fn/*, timeout*/) {
var delay, timeout = arguments[1];
callable(fn);
if (timeout === undefined) {
delay = nextTick;
} else {
timeout = validTimeout(timeout);
delay = setTimeout;
}
return function () {
return delay(apply.bind(fn, this, arguments), timeout);
};
};