Skip to content

Commit a69e60b

Browse files
committed
Fix queue::length and add forEach
1 parent 743eb00 commit a69e60b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,13 +255,15 @@ Queue.prototype.push = function (item) {
255255
return this.tail.push(item);
256256
};
257257

258-
Queue.prototype.length = function () {
259-
return this.head.length - this.offset + this.tail.length;
258+
Queue.prototype.forEach = function () {
259+
var array = this.head.slice(this.offset);
260+
array.push.apply(array, this.tail);
261+
return array.forEach.apply(array, arguments);
260262
};
261263

262264
Object.defineProperty(Queue.prototype, 'length', {
263265
get: function () {
264-
return this.array.length;
266+
return this.head.length - this.offset + this.tail.length;
265267
}
266268
});
267269

0 commit comments

Comments
 (0)