From 777d9eff5f9af74e3627ea0833c58adc98773ac4 Mon Sep 17 00:00:00 2001 From: ansuz Date: Fri, 27 Sep 2019 12:05:56 +0200 Subject: [PATCH] pass arguments to 'throttle' --- www/common/common-util.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/www/common/common-util.js b/www/common/common-util.js index b4255996f..ba9fa2f03 100644 --- a/www/common/common-util.js +++ b/www/common/common-util.js @@ -5,6 +5,10 @@ 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 + Util.slice = function (A, start, end) { + return Array.prototype.slice.call(A, start, end); + }; + Util.bake = function (f, args) { if (typeof(args) === 'undefined') { args = []; } if (!Array.isArray(args)) { args = [args]; } @@ -265,7 +269,7 @@ var to; var g = function () { window.clearTimeout(to); - to = window.setTimeout(f, ms); + to = window.setTimeout(Util.bake(f, Util.slice(arguments)), ms); }; return g; };