@timvanscherpenzeel/object-pooldeprecated

Object pool implementation using two circular linked lists.

Usage no npm install needed!

<script type="module">
  import timvanscherpenzeelObjectPool from 'https://cdn.skypack.dev/@timvanscherpenzeel/object-pool';
</script>

README

Object-pool

npm version dependencies devDependencies

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.