A simple, TypedArray-backed resizable vector data-structure.
Using npm:
$ npm install --save @4bitlabs/vector
Using yarn:
$ yarn add @4bitlabs/vector
Using pnpm:
$ pnpm add @4bitlabs/vector
Full documentation for the library can be found here
import { Vector } from '@4bitlabs/typed-vector';
/* Create a resizable vector of float64s */
const floats = new Vector(Float64Array, { initialCapacity: 10 });
floats.push(Math.random());
console.log(floats.pop());
/* Create a resizable vector of bytes */
const bytes = new Vector(Uint8ClampedArray, { initialCapacity: 255 });
bytes.push(0x10);
console.log(bytes.pop());
Also included is BigVector
for usage with int64
and uint64
sized integers:
import { BigVector } from '@4bitlabs/vector/dist';
const uint64s = new BigVector(BigUint64Array);
uint64s.push(0xffff_ffff_ffff_ffffn);