UNPKG

lettuce

Version:

Lettuce JS, Mini Mobile Framework for Romantic with DSL.

23 lines (22 loc) 767 B
/** * MelonJS Game Engine * (C) 2011 - 2014 Olivier Biot, Jason Oster, Aaron McLeod * http://www.melonjs.org */ /** * Executes a function as soon as the interpreter is idle (stack empty). * @memberof! external:Function# * @alias defer * @param {Object} context The execution context of the deferred function. * @param {} [arguments...] Optional additional arguments to carry for the * function. * @return {Number} id that can be used to clear the deferred function using * clearTimeout * @example * // execute myFunc() when the stack is empty, * // with the current context and 'myArgument' as parameter * myFunc.defer(this, 'myArgument'); */ Function.prototype.defer = function () { return setTimeout(this.bind.apply(this, arguments), 0.01); };