/**@
* #Crafty Time
* @category Utilities
*/
Crafty.c("Delay", {
	init : function() {
		this._delays = [];
		this.bind("EnterFrame", function() {
			var now = new Date().getTime();
			var index = this._delays.length;
			while (--index >= 0) {
				var item = this._delays[index];
				if(item.start + item.delay + item.pause < now) {
					item.func.call(this);
					// remove item from array
					this._delays.splice(index,1);
				}
			}
		});
		this.bind("Pause", function() {
			var now = new Date().getTime();
			for(var index in this._delays) {
				this._delays[index].pauseBuffer = now;
			}
		});
		this.bind("Unpause", function() {
			var now = new Date().getTime();
			for(var index in this._delays) {
				var item = this._delays[index];
				item.pause += now-item.pauseBuffer;
			}
		});
	},
	/**@
	* #.delay
	* @comp Crafty Time
	* @sign public this.delay(Function callback, Number delay)
	* @param callback - Method to execute after given amount of milliseconds
	* @param delay - Amount of milliseconds to execute the method
	* 
	* The delay method will execute a function after a given amount of time in milliseconds.
	* 
	* It is not a wrapper for `setTimeout`.
	* 
	* If Crafty is paused, the delay is interrupted with the pause and then resume when unpaused
	*
	* If the entity is destroyed, the delay is also destroyed and will not have effect. 
	*
	* @example
	* ~~~
	* console.log("start");
	* this.delay(function() {
		 console.log("100ms later");
	* }, 100);
	* ~~~
	*/
	delay : function(func, delay) {
		return this._delays.push({
			start : new Date().getTime(),
			func : func,
			delay : delay,
			pauseBuffer: 0,
			pause: 0
		});
	}
});

@@ -352,16 +352,240 @@
 (this);%0A
+%09%09%09%09%09if (item.repeat %3E 0 ) %7B%0A%09%09%09%09%09%09// reschedule item%0A%09%09%09%09%09%09item.start = now;%0A%09%09%09%09%09%09item.pause = 0;%0A%09%09%09%09%09%09item.pauseBuffer = 0;%0A%09%09%09%09%09%09if (item.repeat !== Infinity)%0A%09%09%09%09%09%09%09item.repeat--;%0A%09%09%09%09%09%7D else if (item.repeat === 0) %7B%0A%09
 %09%09%09%09%09// 
@@ -607,16 +607,17 @@
 m array%0A
+%09
 %09%09%09%09%09thi
@@ -643,16 +643,23 @@
 dex,1);%0A
+%09%09%09%09%09%7D%0A
 %09%09%09%09%7D%0A%09%09
@@ -1259,16 +1259,267 @@
  method%0A
+%09* @param repeat - How often to repeat the delayed function. A value of 0 triggers the delayed%0A%09* function exactly once. A value n %3E 0 triggers the delayed function exactly n+1 times. A%0A%09* value of Infinity triggers the delayed function indefinitely.%0A
 %09* %0A%09* T
@@ -1950,16 +1950,19 @@
 * %7D, 100
+, 0
 );%0A%09* ~~
@@ -2000,21 +2000,22 @@
 elay
-) %7B%0A%09%09return 
+, repeat) %7B%0A%09%09
 this
@@ -2097,16 +2097,40 @@
  delay,%0A
+%09%09%09repeat: repeat %7C%7C 0,%0A
 %09%09%09pause
@@ -2158,15 +2158,30 @@
 0%0A%09%09%7D);%0A
+%09%09return this;%0A
 %09%7D%0A%7D);%0A

Update time.js