pass arguments to 'throttle'

pull/1/head
ansuz 5 years ago
parent 83c19f01f3
commit 777d9eff5f

@ -5,6 +5,10 @@
window.atob = window.atob || function (str) { return Buffer.from(str, 'base64').toString('binary'); }; // jshint ignore:line window.atob = window.atob || function (str) { return Buffer.from(str, 'base64').toString('binary'); }; // jshint ignore:line
window.btoa = window.btoa || function (str) { return new Buffer(str, 'binary').toString('base64'); }; // jshint ignore:line window.btoa = window.btoa || function (str) { return new Buffer(str, 'binary').toString('base64'); }; // jshint ignore:line
Util.slice = function (A, start, end) {
return Array.prototype.slice.call(A, start, end);
};
Util.bake = function (f, args) { Util.bake = function (f, args) {
if (typeof(args) === 'undefined') { args = []; } if (typeof(args) === 'undefined') { args = []; }
if (!Array.isArray(args)) { args = [args]; } if (!Array.isArray(args)) { args = [args]; }
@ -265,7 +269,7 @@
var to; var to;
var g = function () { var g = function () {
window.clearTimeout(to); window.clearTimeout(to);
to = window.setTimeout(f, ms); to = window.setTimeout(Util.bake(f, Util.slice(arguments)), ms);
}; };
return g; return g;
}; };

Loading…
Cancel
Save