Skip to content

Instantly share code, notes, and snippets.

@swvitaliy
Created October 17, 2012 05:00
Show Gist options
  • Save swvitaliy/3903784 to your computer and use it in GitHub Desktop.
Save swvitaliy/3903784 to your computer and use it in GitHub Desktop.
js maxTimeout
var maxTimeoutLoopExecutionTemplate = "(function (maxTimeout, fn, delay) {" +
" var t;" +
" setTimeout(function () { clearTimeout(t); }, maxTimeout);" +
" t = (function z() { return setTimeout(function () { fn(); t = z(); }, delay); })();" +
"})(:maxtimeout, function () { :expression }, :delay);";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment