bit-utils
Bitlist/Bitvector Utilities
Install
npm install @chainsafe/bit-utils
Examples
BitList
import {BitList} from "@chainsafe/bit-utils";
const list: BitList = BitList.fromBitfield(Buffer.from([3]), 3);
const list2: BitList = BitList.deserialize(Buffer.from([11]));
const _bitLength = list.bitLength;
list.setBit(0, true);
list.getBit(0) === true;
const output: Uint8Array = list.toBitfield();
const output2: Uint8Array = list.serialize();
BitVector
import {BitVector} from "@chainsafe/bit-utils";
const vector: BitVector = BitVector.fromBitfield(Buffer.from([3]), 3);
const _bitLength = vector.bitLength;
vector.setBit(0, true);
vector.getBit(0) === true
const output: Uint8Array = vector.toBitfield();
API
See our autogenerated API docs
License
Apache 2.0