Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tomeraberbach/quetie
🎀 Just the cutest and tiniest queue/deque implementation!
https://github.com/tomeraberbach/quetie
amortized-array data-structures deque double-ended-queue npm-module npm-package queue stack
Last synced: 25 days ago
JSON representation
🎀 Just the cutest and tiniest queue/deque implementation!
- Host: GitHub
- URL: https://github.com/tomeraberbach/quetie
- Owner: TomerAberbach
- License: apache-2.0
- Created: 2021-06-28T02:40:45.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-13T23:57:22.000Z (7 months ago)
- Last Synced: 2024-04-14T13:12:31.231Z (7 months ago)
- Topics: amortized-array, data-structures, deque, double-ended-queue, npm-module, npm-package, queue, stack
- Language: JavaScript
- Homepage: https://npm.im/quetie
- Size: 255 KB
- Stars: 110
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Contributing: contributing.md
- License: license
Awesome Lists containing this project
README
quetie
Just the cutest and tiniest queue/deque implementation!## Features
- **Tiny:** ~360 bytes minzipped!
- **Fast:**
[amortized O(1) time complexity](https://en.wikipedia.org/wiki/Amortized_analysis)
for all operations
- **Tree Shakeable:** use `Queue` if you don't need a full `Deque`!## Install
```sh
$ npm i quetie
```## Usage
```js
import { Deque, Queue } from 'quetie'const queue = new Queue()
queue.push(1)
queue.push(2)
queue.push(3)console.log(queue.size)
//=> 3console.log(queue.at(0))
console.log(queue.at(1))
console.log(queue.at(2))
console.log(queue.at(3))
console.log(queue.at(-1))
//=> 1
//=> 2
//=> 3
//=> 1
//=> 3console.log([...queue])
//=> [ 1, 2, 3 ]console.log(queue.shift())
console.log(queue.shift())
console.log(queue.shift())
console.log(queue.shift())
//=> 1
//=> 2
//=> 3
//=> undefinedconst deque = new Deque()
deque.push(1)
deque.push(2)
deque.push(3)
deque.unshift(0)console.log(deque.size)
//=> 4console.log(deque.at(0))
console.log(deque.at(1))
console.log(deque.at(2))
console.log(deque.at(3))
console.log(deque.at(-1))
//=> 0
//=> 1
//=> 2
//=> 3
//=> 3console.log([...deque])
//=> [ 0, 1, 2, 3 ]console.log(deque.pop())
console.log(deque.shift())
console.log(deque.shift())
console.log(deque.pop())
console.log(deque.pop())
//=> 3
//=> 0
//=> 1
//=> 2
//=> undefined
```See the
[type definitions](https://github.com/TomerAberbach/quetie/blob/main/src/index.d.ts)
for more documentation.## Contributing
Stars are always welcome!
For bugs and feature requests,
[please create an issue](https://github.com/TomerAberbach/quetie/issues/new).For pull requests, please read the
[contributing guidelines](https://github.com/TomerAberbach/quetie/blob/master/contributing.md).## License
[Apache 2.0](https://github.com/TomerAberbach/quetie/blob/master/license)
This is not an official Google product.