1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

Fix queue::length and add forEach

This commit is contained in:
Tim-Smart
2010-09-17 23:08:50 +12:00
parent 743eb00234
commit a69e60b70f

View File

@@ -255,13 +255,15 @@ Queue.prototype.push = function (item) {
return this.tail.push(item);
};
Queue.prototype.length = function () {
return this.head.length - this.offset + this.tail.length;
Queue.prototype.forEach = function () {
var array = this.head.slice(this.offset);
array.push.apply(array, this.tail);
return array.forEach.apply(array, arguments);
};
Object.defineProperty(Queue.prototype, 'length', {
get: function () {
return this.array.length;
return this.head.length - this.offset + this.tail.length;
}
});