abstract-pool
v2.0.0
Published
unopinionated object pooling
Downloads
2
Readme
abstract-pool
This is a simple, unopinionated module for creating and consuming pools of objects. It’s inspired by dom-pool, but can be used outside of DOM-based environments.
Install
$ npm install abstract-pool
Usage
var pool = require('abstract-pool')
var i = 0
var numbers = pool(function () {
return ++i
})
numbers.alloc(5)
numbers.pop()
=> 5
var number = numbers.pop()
console.log(number)
=> 4
numbers.push(number)
numbers.pop()
=> 4
numbers.dealloc(2)
numbers.pop()
=> 1
page weight (browserified)
| compression | size | | :---------------------- | ------: | | abstract-pool.js | 1.17 kB | | abstract-pool.min.js | 882 B | | abstract-pool.min.js.gz | 433 B |