@biorate/bit-array

1.23.1 • Public • Published

Bit array class

The BitArray class is for setting and extracting bits from a number. It can be used, for example, for compact storage array of boolean values.

Features:

  • compact storage array of boolean values

Examples:

import { BitArray } from '@biorate/bit-array';

const bits = new BitArray();

bits.set(0);
bits.set(1);
bits.set(2);

console.log(bits.value(0)); // 1
console.log(bits.value(0, 1)); // 3
console.log(bits.value(0, 1, 2)); // 7

bits.remove(1);

console.log(bits.value(0)); // 1
console.log(bits.value(0, 1)); // 1
console.log(bits.value(0, 1, 2)); // 5

Learn

  • Documentation can be found here - docs.

Release History

See the CHANGELOG

License

MIT

Copyright (c) 2021-present Leonid Levkin (llevkin)

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i @biorate/bit-array

      Weekly Downloads

      2

      Version

      1.23.1

      License

      MIT

      Unpacked Size

      113 kB

      Total Files

      26

      Last publish

      Collaborators

      • llevkin