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);
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user