From a3ed49a5ed44c6fae01b3f059cb7e3a64e445f4a Mon Sep 17 00:00:00 2001 From: Christian Williams Date: Mon, 12 Oct 2009 21:02:50 -0500 Subject: [PATCH] Refactor. --- src/Queue.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Queue.js b/src/Queue.js index 01ebd10..061c222 100644 --- a/src/Queue.js +++ b/src/Queue.js @@ -6,7 +6,7 @@ jasmine.Queue = function(env) { this.offset = 0; }; -jasmine.Queue.prototype.addBefore = function (block) { +jasmine.Queue.prototype.addBefore = function(block) { this.blocks.unshift(block); }; @@ -14,7 +14,7 @@ jasmine.Queue.prototype.add = function(block) { this.blocks.push(block); }; -jasmine.Queue.prototype.insertNext = function (block) { +jasmine.Queue.prototype.insertNext = function(block) { this.blocks.splice((this.index + this.offset + 1), 0, block); this.offset++; }; @@ -25,28 +25,27 @@ jasmine.Queue.prototype.start = function(onComplete) { this.next_(); }; -jasmine.Queue.prototype.isRunning = function () { +jasmine.Queue.prototype.isRunning = function() { return this.running; }; var nestLevel = 0; -jasmine.Queue.prototype.next_ = function () { +jasmine.Queue.prototype.next_ = function() { var self = this; if (self.index < self.blocks.length) { self.blocks[self.index].execute(function () { - var doNext = function () { - self.offset = 0; - self.index++; - self.next_(); - }; + self.offset = 0; + self.index++; var now = new Date().getTime(); if (self.env.updateInterval && now - self.env.lastUpdate > self.env.updateInterval) { self.env.lastUpdate = now; - self.env.setTimeout(doNext, 0); + self.env.setTimeout(function() { + self.next_(); + }, 0); } else { - doNext(); + self.next_(); } }); } else { @@ -57,7 +56,7 @@ jasmine.Queue.prototype.next_ = function () { } }; -jasmine.Queue.prototype.results = function () { +jasmine.Queue.prototype.results = function() { var results = new jasmine.NestedResults(); for (var i = 0; i < this.blocks.length; i++) { if (this.blocks[i].results) {