@4bitlabs/vector
TypeScript icon, indicating that this package has built-in type declarations

0.2.2 • Public • Published

@4bitlabs/vector

A simple, TypedArray-backed resizable vector data-structure.

Installing

Using npm:

$ npm install --save @4bitlabs/vector

Using yarn:

$ yarn add @4bitlabs/vector

Using pnpm:

$ pnpm add @4bitlabs/vector

Documentation

Full documentation for the library can be found here

Usage

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);

License

ISC

Package Sidebar

Install

npm i @4bitlabs/vector

Weekly Downloads

1

Version

0.2.2

License

ISC

Unpacked Size

53.4 kB

Total Files

27

Last publish

Collaborators

  • 32bitkid