Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/smikhalevski/object-pool
🤿 The tiny and efficient object pool.
https://github.com/smikhalevski/object-pool
caching object-pool performance
Last synced: 4 days ago
JSON representation
🤿 The tiny and efficient object pool.
- Host: GitHub
- URL: https://github.com/smikhalevski/object-pool
- Owner: smikhalevski
- License: mit
- Created: 2021-09-03T19:21:26.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2021-12-17T12:24:10.000Z (almost 3 years ago)
- Last Synced: 2024-11-07T23:12:09.761Z (7 days ago)
- Topics: caching, object-pool, performance
- Language: TypeScript
- Homepage:
- Size: 90.8 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# object-pool [![build](https://github.com/smikhalevski/object-pool/actions/workflows/master.yml/badge.svg?branch=master&event=push)](https://github.com/smikhalevski/object-pool/actions/workflows/master.yml)
[The tiny](https://bundlephobia.com/package/@smikhalevski/object-pool) and efficient object pool.
This implementation was inspired by [deePool](https://github.com/getify/deePool) and is slightly faster than the
original.```shell
npm install @smikhalevski/object-pool
```# Usage
```ts
import {ObjectPool} from '@smikhalevski/object-pool';const pool = new ObjectPool(() => {
// Create and return a heavy object.
}, (value) => {
// Reset the released object.
});// Prepare 100 heavy objects.
pool.allocate(100);// Take a heavy object from the pool.
const heavyObject = pool.take();// Return heavy object back to the pool.
pool.release(heavyObject);
```