mirror of
https://github.com/cryptpad/cryptpad.git
synced 2026-09-14 11:05:41 +05:00
update util.once to add a handler for multiple callbacks
This commit is contained in:
parent
1d5534b593
commit
56ec91ff27
@ -222,13 +222,14 @@
|
||||
return Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);
|
||||
};
|
||||
|
||||
Util.noop = function () {};
|
||||
|
||||
/* for wrapping async functions such that they can only be called once */
|
||||
Util.once = function (f) {
|
||||
var called;
|
||||
Util.once = function (f, g) {
|
||||
return function () {
|
||||
if (called) { return; }
|
||||
called = true;
|
||||
if (!f) { return; }
|
||||
f.apply(this, Array.prototype.slice.call(arguments));
|
||||
f = g;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user