Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cadienvan/expirables
This is a zero dependency package that provides some expirable implementations of common Data Structures.
https://github.com/cadienvan/expirables
data-structures javascript nodejs typescript
Last synced: 10 days ago
JSON representation
This is a zero dependency package that provides some expirable implementations of common Data Structures.
- Host: GitHub
- URL: https://github.com/cadienvan/expirables
- Owner: Cadienvan
- License: mit
- Created: 2022-12-11T09:46:59.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-17T22:10:40.000Z (7 months ago)
- Last Synced: 2024-05-18T01:26:04.711Z (7 months ago)
- Topics: data-structures, javascript, nodejs, typescript
- Language: TypeScript
- Homepage:
- Size: 2.37 MB
- Stars: 21
- Watchers: 3
- Forks: 5
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
![Expirables Logo](./expirables.png)
# What is this?
This is a zero dependency package that provides some expirable implementations of common Data Structures.
Thanks to the [npm-package-ts-scaffolding](https://github.com/Cadienvan/npm-package-ts-scaffolding) it is importable both via CommonJS and ES Modules.
It currently supports the following Data Structures:- [ExpirableMap](./packages/website/docs/map.md)
- [ExpirableSet](./packages/website/docs/set.md)
- [ExpirableQueue](./packages/website/docs/queue.md)
- [ExpirableStack](./packages/website/docs/stack.md)
- [ExpirableLinkedList](./packages/website/docs/linked-list.md)# How do I install it?
You can install it by using the following command:
```bash
npm install expirables
```# Tests
You can run the tests by using the following command:
```bash
npm test
```# Scaffolding
This project was generated using Cadienvan's own [npm-package-ts-scaffolding](https://github.com/Cadienvan/npm-package-ts-scaffolding) so it has all the necessary tools to develop, test and publish a TypeScript package importable both via CommonJS and ES Modules.
# FAQ
## Why are you using timeouts instead of lazy evaluation?
- Lazy evaluation would need to re-implement many methods of the Data Structures and would be much more complex to implement and maintain.
- Lazy evaluation could block the main thread for a long time if the Data Structure is big, and moving it to a Worker would be a lot of work for a small gain.
- Lazy evaluation would require a higher amount of memory to work because it would store all the expired entries until they are evaluated.
- Lazy evaluation would need us to store additional information about the entries (e.g. the expiration time) which would increase the memory footprint of the Data Structure.# Contributing
If you want to contribute to this project, please open an issue or a pull request.