allocated-dynamic-typedarray
Allocate an entire array, but automatically track which indices are occupied.
Example
var ADTA = require('allocated-dynamic-typedarray');
var a = new ADTA(64);
a.length();
a.push(72);
a.length();
a.get(0);
a.push(23);
a.push(34);
a.push(56);
a.length()
a.remove(1);
a.length();
a.toArray();
Notice how the order of the items is not guaranteed after a .remove()
. This is to prevent needing to shift or push all values. If you need functionality otherwise, try a different module.
Pushing a value that would cause the array to exceed it's initial limit silently fails for now, as that's why TypedArrays do.
Since this is backed by a TypedArray, only values that could normally be stored in a TypedArray will succeed.
Contributing
npm test
Pull requests are welcome!
License
MIT