implement 'mkTimeout' method in common-util

pull/1/head
ansuz 5 years ago
parent a172bad30f
commit 2df65ed446

@ -68,6 +68,19 @@
}; };
}; };
Util.mkTimeout = function (_f, ms) {
ms = ms || 0;
var f = Util.once(_f);
var timeout = setTimeout(function () {
f('TIMEOUT');
}, ms);
return Util.both(f, function () {
clearTimeout(timeout);
});
};
Util.response = function () { Util.response = function () {
var pending = {}; var pending = {};
var timeouts = {}; var timeouts = {};

Loading…
Cancel
Save