DEV Community

Michael Di Prisco
Michael Di Prisco

Posted on • Edited on

My Journey in Open Source - expirables

Link to the repo

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 it is importable both via CommonJS and ES Modules.

It currently supports the following Data Structures:

How do I install it?

You can install it by using the following command:

npm install expirables
Enter fullscreen mode Exit fullscreen mode

Tests

You can run the tests by using the following command:

npm test
Enter fullscreen mode Exit fullscreen mode

Scaffolding

This project was generated using Cadienvan's own 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.

API Trace View

How I Cut 22.3 Seconds Off an API Call with Sentry 👀

Struggling with slow API calls? Dan Mindru walks through how he used Sentry's new Trace View feature to shave off 22.3 seconds from an API call.

Get a practical walkthrough of how to identify bottlenecks, split tasks into multiple parallel tasks, identify slow AI model calls, and more.

Read more →

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more