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.
- compact storage array of boolean values
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
- Documentation can be found here - docs.
See the CHANGELOG
Copyright (c) 2021-present Leonid Levkin (llevkin)