1 define(['../time/now', './timeout', '../array/append'], function (now, timeout, append) {
4 * Ensure a minimum delay for callbacks
6 function awaitDelay( callback, delay ){
7 var baseTime = now() + delay;
9 // ensure all browsers will execute it asynchronously (avoid hard
10 // to catch errors) not using "0" because of old browsers and also
11 // since new browsers increase the value to be at least "4"
12 // http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#dom-windowtimers-settimeout
13 var ms = Math.max(baseTime - now(), 4);
14 return timeout.apply(this, append([callback, ms, this], arguments));