Skip to content

smikhalevski/object-pool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

object-pool build

The tiny and efficient object pool.

This implementation was inspired by deePool and is slightly faster than the original.

npm install @smikhalevski/object-pool

Usage

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);

About

🤿 The tiny and efficient object pool.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published