You've already forked node-redis
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:
8
index.js
8
index.js
@@ -255,13 +255,15 @@ Queue.prototype.push = function (item) {
|
|||||||
return this.tail.push(item);
|
return this.tail.push(item);
|
||||||
};
|
};
|
||||||
|
|
||||||
Queue.prototype.length = function () {
|
Queue.prototype.forEach = function () {
|
||||||
return this.head.length - this.offset + this.tail.length;
|
var array = this.head.slice(this.offset);
|
||||||
|
array.push.apply(array, this.tail);
|
||||||
|
return array.forEach.apply(array, arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.defineProperty(Queue.prototype, 'length', {
|
Object.defineProperty(Queue.prototype, 'length', {
|
||||||
get: function () {
|
get: function () {
|
||||||
return this.array.length;
|
return this.head.length - this.offset + this.tail.length;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user