https://github.com/magic-akari/yocto_queue
https://github.com/magic-akari/yocto_queue
deno queue
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/magic-akari/yocto_queue
- Owner: magic-akari
- License: mit
- Created: 2021-05-03T11:52:40.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-05-21T03:35:36.000Z (about 2 years ago)
- Last Synced: 2024-05-21T04:38:50.406Z (about 2 years ago)
- Topics: deno, queue
- Language: TypeScript
- Homepage: https://deno.land/x/yocto_queue
- Size: 24.4 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# yocto_queue
Same as [yocto-queue](https://www.npmjs.com/package/yocto-queue) but for Deno.
## Usage
```typescript
import { Queue } from "https://deno.land/x/yocto_queue@VERSION/mod.ts";
const queue = new Queue();
queue.enqueue("π¦");
queue.enqueue("π");
console.log(queue.size);
//=> 2
console.log(...queue);
//=> 'π¦ π'
console.log(queue.dequeue());
//=> 'π¦'
console.log(queue.dequeue());
//=> 'π'
```
## API
### `queue = new 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.
#### `.enqueue(value)`
Add a value to the queue.
#### `.enqueue(...values)`
Add multiply values to the queue.
#### `.dequeue()`
Remove the next value in the queue.
Returns the removed value or `undefined` if the queue is empty.
#### `.clear()`
Clear the queue.
#### `.size`
The size of the queue.