0.0.10 • Published 5 years ago
@timvanscherpenzeel/object-pool v0.0.10
Object-pool
Object pool implementation using two circular linked lists.
Installation
$ npm install --save @timvanscherpenzeel/object-pool
Usage
$ npm run lint
$ npm run test
$ npm run test:coverage
$ npm run dist
$ npm run deploy
const ObjectPool = require('@timvanscherpenzeel/object-pool');
const objectPool = new ObjectPool({
poolSize: 25,
});
const poolNode = objectPool.alloc();
poolNode.example = 'example property';
objectPool.free(poolNode);
poolNode = null;
API
objectPool.alloc()
- Return Type:
{ key: string }
Allocates an object from the reservePool and puts it into the activePool. Returns the object and marks it with a unique key in order to be cleaned up later.
objectPool.free()
- Return Type:
void
Frees an object from the activePool, cleans up its properties and puts it into the reservePool.
Licence
My work is released under the MIT licence.