Debounce a function.
@param {function} f The function.
@param {number} delay The delay in ms.
@return {function} A function which calls the passed-in function debounced.
778159
function debounce(f, delay) {
  var timeoutId = null;

  return function debounceExecute_() {
    clearTimeout(timeoutId);
    var lastArgs = arguments;

    timeoutId = setTimeout(function() {
      timeoutId = null;
      f.apply(null, lastArgs);
    }, delay);
  };
}
1289004
function _flw_stop(reason, cb) {
      if (!cb && typeof reason === 'function') {
        cb = reason;
        reason = 'stopped';
      }
      c._stopped = reason;
      return cb();
    }
418241
function nextFrame(fn) {
    let frame;
    let cancelFrame;

    if (window.requestAnimationFrame) {
        frame = requestAnimationFrame(() => {
            frame = requestAnimationFrame(fn);
        });
        cancelFrame = cancelAnimationFrame;
    } else {
        frame = setTimeout(fn, 26); // 16ms to simulate RAF, 10ms to ensure called after the frame.
        cancelFrame = clearTimeout;
    }

    return () => {
        if (frame) {
            cancelFrame(frame);
            frame = undefined;
        }
    };
}
1258199
function(func,factor) {
		return function() {

			/* globals setTimeout: false */

			var args = Array.prototype.slice.call(arguments),
				cb;
			while (typeof args.slice(-1)[0] === 'function') {
				cb = args.pop();
			}
			if (factor === false) {
				return cb(func.apply(this._inst,args));
			}
			setTimeout(function() {
				var r = [func.apply(this._inst,args)];
				if (nodeStyle) {
					r.unshift(null);
				}
				cb.apply(this, r);
			}.bind(this),Math.floor(Math.random() * factor) + 1);
		};
	}
983688
function startTimeout(func, time, self) {
  return {
    timer: setTimeout(func.bind(self), time),
    stopped: false
  };
}
790692
function (func, delay) {
    var timer = null;

    return function () {
      var context = this, args = arguments;

      if (timer === null) {
        timer = setTimeout(function () {
          func.apply(context, args);
          timer = null;
        }, delay);
      }
    };
  }
984392
function(delay) {
			if(this.isTurnedOff){
				return;
			}
			if (this.isShowing()) { //$NON-NLS-0$
				return;
			}
			if (this._timeout) {
				window.clearTimeout(this._timeout);
				this._timeout = null;
			}
			var showDelay = delay !== undefined ? delay : this._showDelay;
			if (showDelay) {
				this._timeout = window.setTimeout(this._showImmediately.bind(this), showDelay);	
			} else {
				this._showImmediately();
			}
		}
712857
def delay(fn, opts, task, *args, **kwargs):
    
    if opts["stddev"] <= 0:
        t = opts["t"]
    elif opts["pdf"] == "gauss":
        t = random.gauss(opts["t"], opts["stddev"])
    elif opts["pdf"] == "uniform":
        t = random.uniform(opts["t"], opts["stddev"])
    else:
        raise ValueError("unknown delay decorator pdf '{}'".format(opts["pdf"]))

    time.sleep(t)

    return fn(task, *args, **kwargs)
1217801
function AnimationThrottler(delay) {
  if(!delay) delay = DELAY;

  // Anim is considered active if it's running or queued
  var currentDelay = 0;

  // func: Function that takes no params and returns a promise
  function requestAnim(func) {
    var result = q.delay(currentDelay)
      .thenResolve(func)
      .then(start);
    currentDelay += delay;
    return result;
  }
  this.requestAnim = requestAnim;

  function start(func) {
    return func()
      .catch(animFailed)
      .tap(animFinished);
  }

  function animFailed(error) {
    animFinished();
    throw error;
  }

  function animFinished() {
    currentDelay -= delay;
  }
}
1168920
function(func, arr, opts) {
		var dfrd = $.Deferred(),
			abortFlg = false,
			parms = Object.assign({
				interval : 0,
				numPerOnce : 1
			}, opts || {}),
			resArr = [],
			vars =[],
			curVars = [],
			exec,
			tm;
		
		dfrd._abort = function(resolve) {
			tm && clearTimeout(tm);
			vars = [];
			abortFlg = true;
			if (dfrd.state() === 'pending') {
				dfrd[resolve? 'resolve' : 'reject'](resArr);
			}
		};
		
		dfrd.fail(function() {
			dfrd._abort();
		}).always(function() {
			dfrd._abort = function() {};
		});

		if (typeof func === 'function' && Array.isArray(arr)) {
			vars = arr.concat();
			exec = function() {
				var i, len, res;
				if (abortFlg) {
					return;
				}
				curVars = vars.splice(0, parms.numPerOnce);
				len = curVars.length;
				for (i = 0; i < len; i++) {
					if (abortFlg) {
						break;
					}
					res = func(curVars[i]);
					(res !== null) && resArr.push(res);
				}
				if (abortFlg) {
					return;
				}
				if (vars.length) {
					tm = setTimeout(exec, parms.interval);
				} else {
					dfrd.resolve(resArr);
				}
			};
			if (vars.length) {
				tm = setTimeout(exec, 0);
			} else {
				dfrd.resolve(resArr);
			}
		} else {
			dfrd.reject();
		}
		return dfrd;
	}
770957
function(fnc, cacheId, delay, scope, parameters, strategy) {
            var self = this,
                LOOP = "loop";

            if (!fnc) {
                return;
            }

            cacheId = cacheId || fnc.toString();
            scope = scope || this;
            parameters = parameters || [];
            strategy = strategy || LOOP;

            if (delay === 0) {
                // immediately invoke function
                fnc.apply(scope, parameters);
                return;
            }

            delay = delay || 300;
            if (this.$debounceTimeoutMap[cacheId]) {
                // timer registered

                if (strategy === LOOP) {
                    return;
                }

                clearTimeout(this.$debounceTimeoutMap[cacheId]);
            }

            this.$debounceTimeoutMap[cacheId] = setTimeout(function() {
                delete self.$debounceTimeoutMap[cacheId];
                fnc.apply(scope, parameters);
            }, delay);
        }
756925
function(key, delay, args) {
        this.clearTimer(key);

        var func;

        if (key === 'show') {
            func = this.position;
        } else {
            func = this.hide;
        }

        if (func) {
            this.timers[key] = setTimeout(function() {
                func.apply(this, args || []);
            }.bind(this), delay);
        }
    }
1124699
function debounce(callback){
  var queued = false;
  return function () {
    if(!queued){
      queued = true;
      setTimeout(function () {
        queued = false;
        callback();
      }, 0);
    }
  };
}
409782
function delay(timeout, value) {
        if (timeout < 0) {
            return value;
        }

        var future = new Future();
        setTimeout(function () {
            future.resolve(value);
        }, timeout);
        return future;
    }
1144928
function delay (callback, wait) {
  var args = arraySlice(arguments, 2)
  var context = this
  return setTimeout(function () {
    callback.apply(context, args)
  }, wait)
}
571064
function DebounceTask(proc, { wait, options }) {
  this.lastTask = undefined;
  this.maxWait = undefined;
  this.timerId = undefined;
  this.lastCallTime = undefined;
  this.lastInvokeTime = 0;
  this.leading = false;
  this.maxing = false;
  this.trailing = true;
  this.wait = +wait || 0;

  if (is.object(options)) {
    this.leading = !!options.leading;
    this.maxing = 'maxWait' in options;
    this.maxWait = this.maxing ? Math.max(+options.maxWait || 0, this.wait) : this.maxWait;
    this.trailing = 'trailing' in options ? !!options.trailing : this.trailing;
  }

  this.proc = proc;
  this.timerExpired = this.timerExpired.bind(this);
  this.finish = noop;
}
68358
function setTimeoutContext(fn, ctx, timeout) {
  var id;

  var cancel = function() {
    clearTimeout(id);
  };

  id = setTimeout(function() {
    ctx.removeListener('cancel', cancel);

    fn();
  }, timeout);

  ctx.once('cancel', cancel);
}