1.0.2 • Published 6 years ago

fast-reusable-id v1.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

fast reusable sequential integer ids

var FastRusableId = require('fast-reusable-id');

var start_id = 100; //all ids will start at 100
var max_id = 1000; //will throw error when you get id over 1000, defaults to 100000
var force_recycle = false; //will force to use released ids before reaching the max possible id, otherwise will use all possible ids up to max and then go through the pool of released ids and use them until it is empty.
var optional_typed_array = undefined // defaults to Uint32Array


var my_id_pool = new FastReusableId
//or pass with optional parameters
var my_id_pool = new FastReusableId(start_id,max_id,force_recycle,optional_typed_array); //pool to get ids from


var unique_id = my_id_pool.get() //get a fresh unique id
my_id_pool.release(unique_id) //im done with this id, release it into the pool to be used later