Skip to content

Instantly share code, notes, and snippets.

@costa
Created June 26, 2011 12:32
Show Gist options
  • Save costa/1047573 to your computer and use it in GitHub Desktop.
Save costa/1047573 to your computer and use it in GitHub Desktop.
var _timeBuffer = (function() {
var tos = {};
return function(act, func, min, max) {
function _doFunc() {
var to = tos[act]; tos[act] = null;
if (to) { clearTimeout(to.max); clearTimeout(to.min); }
func();
}
var to = tos[act];
if (to) { clearTimeout(to.min) }
else { tos[act] = to = { max: setTimeout(_doFunc, max) } }
to.min = setTimeout(_doFunc, min);
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment