1.0.1 • Published 1 month ago

simple-object-pool v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

Simple Object Pool

Super lightweight implementation of factory-based object pool.\ There is no error handling if the same object is released into the pool to keep it fast.

Library API

import ObjectPool from "simple-object-pool";

const objPool = new ObjectPool(() => {
    return { hello: "world" };
});

Get objects from pool

const obj1 = objPool.get();
const obj2 = objPool.get();
const obj3 = objPool.get();

Put objects back into the pool

objPool.release(obj1);
// put multiple objects back into the pool
objPool.releaseAll([obj2, obj3]);
console.log(objPool.size()); // 3

Delete all objects in a pool

objPool.clear();
console.log(objPool.size()); // 0

License

License

All code and documentation are (c) 2023 Eugene Shumilin and released under the MIT License. A copy of the MIT License is also included.

1.0.1

1 month ago

1.0.0

9 months ago

0.0.0

9 months ago

0.0.3

9 months ago

0.0.2

9 months ago

0.0.1

9 months ago