@iter-tools/queue
Advanced tools
Comparing version 1.4.1 to 1.5.0
@@ -18,2 +18,12 @@ const Queue = require('../queue.cjs'); | ||
it('can clear values', () => { | ||
const q = new Queue([1, 2, 3]); | ||
const iter = q[Symbol.iterator](); | ||
q.clear(); | ||
expect([...q]).toEqual([]); | ||
expect([...iter]).toEqual([]); | ||
}); | ||
it('can shift the values that are pushed to it', () => { | ||
@@ -20,0 +30,0 @@ const q = new Queue(); |
@@ -14,53 +14,22 @@ /** | ||
/** | ||
* An optional iterable of `values` to be pushed into the queue | ||
* in sequence. If `null` or `undefined` are passed the queue will | ||
* have no initial values. | ||
*/ | ||
constructor(values?: Iterable<T> | null); | ||
/** | ||
* The number of values in the queue | ||
*/ | ||
readonly size: number; | ||
/** | ||
* Returns the value at the head of the queue. | ||
*/ | ||
clear(): void; | ||
peek(): T | undefined; | ||
/** | ||
* Removes the value at the head of the queue and returns it. | ||
*/ | ||
shift(): T | undefined; | ||
/** | ||
* Adds `value` at the tail of the queue. | ||
*/ | ||
push(value: T): void; | ||
/** | ||
* Calls `cb(value, index, queue)` for each value in the queue. | ||
*/ | ||
forEach(cb: (value: T, index: number, queue: Queue) => any): void; | ||
/** | ||
* Yields sequential 0-based indexes, one for each queued value. | ||
* The index 0 indicates the head. | ||
*/ | ||
keys(): IterableIterator<number>; | ||
/** | ||
* Yields the queued values from head to tail. | ||
*/ | ||
values(): IterableIterator<T>; | ||
/** | ||
* Yields an `[index,value]` tuple for each value in the list. | ||
*/ | ||
entries(): IterableIterator<[number, T]>; | ||
/** | ||
* The default iterator. Equivalent to `values()`. | ||
*/ | ||
[Symbol.iterator](): IterableIterator<T>; | ||
@@ -67,0 +36,0 @@ } |
{ | ||
"name": "@iter-tools/queue", | ||
"version": "1.4.1", | ||
"version": "1.5.0", | ||
"description": "An es6-style iterable queue", | ||
@@ -5,0 +5,0 @@ "main": "lib/queue.cjs", |
@@ -55,2 +55,7 @@ # @iter-tools/queue | ||
/** | ||
* Empties the queue of all values. | ||
*/ | ||
clear(); | ||
/** | ||
* Returns the value at the head of the queue. | ||
@@ -57,0 +62,0 @@ */ |
Sorry, the diff of this file is not supported yet
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
0
103
9204
200