🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →

yocto-queue

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yocto-queue - npm Package Compare versions

Comparing version

to
1.2.0

@@ -36,5 +36,19 @@ export default class Queue<ValueType> implements Iterable<ValueType> {

/**
The instance is an [`Iterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols), which means you can iterate over the queue front to back with a “for…of” loop. Using the iterator will not remove the items from the queue. If you want that, use `drain()` instead.
You can also use spreading to convert the queue to an array. Don't do this unless you really need to though, since it's slow.
*/
[Symbol.iterator](): IterableIterator<ValueType>;
/**
Returns an iterator that dequeues items as you consume it.
This allows you to empty the queue while processing its items.
If you want to not remove items as you consume it, use the `Queue` object as an iterator.
*/
drain(): IterableIterator<ValueType>;
/**
Add a value to the queue.

@@ -41,0 +55,0 @@ */

@@ -78,2 +78,9 @@ /*

}
* drain() {
let current;
while ((current = this.dequeue()) !== undefined) {
yield current;
}
}
}
{
"name": "yocto-queue",
"version": "1.1.1",
"version": "1.2.0",
"description": "Tiny queue data structure",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -42,4 +42,6 @@ # yocto-queue [![](https://badgen.net/bundlephobia/minzip/yocto-queue)](https://bundlephobia.com/result?p=yocto-queue)

The instance is an [`Iterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols), which means you can iterate over the queue front to back with a “for…of” loop, or use spreading to convert the queue to an array. Don't do this unless you really need to though, since it's slow.
The instance is an [`Iterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols), which means you can iterate over the queue front to back with a “for…of” loop. Using the iterator will not remove the items from the queue. If you want that, use [`drain()`](#drain) instead.
You can also use spreading to convert the queue to an array. Don't do this unless you really need to though, since it's slow.
#### `.enqueue(value)`

@@ -61,2 +63,10 @@

#### `.drain()`
Returns an iterator that dequeues items as you consume it.
This allows you to empty the queue while processing its items.
If you want to not remove items as you consume it, use the `Queue` object as an iterator.
#### `.clear()`

@@ -63,0 +73,0 @@