uint-n-array
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

UintNArray: UintArray with variable size

npm version

Native JavaScript UintArray only supports 8, 16, or 32 bit sizes (Uint8Array, Uint16Array, and Uint32Array respetively). UintNArray extends them, by supporting variable size of the bit from 1 to 32.

Run demo on RunKit.

How to install

npm i --save uint-n-array

How to use

Import Package

const UintNArray = require('uint-n-array').default;

or

import UintNArray from 'uint-n-array';

Convert data list to the buffer

const input = [6, 2, 4, 0, 3, 1, 2, 0, 7];	
// UintArray with n=3
const buffer = UintNArray.encode(3, input);
console.log(buffer);

Convert buffer to the data list

// UintArray with n=14
const decoded = UintNArray.decode(14, buffer);
console.log(decoded); 

Readme

Keywords

none

Package Sidebar

Install

npm i uint-n-array

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

22.4 kB

Total Files

11

Last publish

Collaborators

  • prevdev