Fast(est) & consistent JavaScript BitSet (AKA bitvector, bitarray, bitstring) implementation. Implemented as part of my upcoming(...loading...) cell game engine, but perfectly usable as a standalone lib.
Features
- Fast!
- Fully tested
- Fully documented
- Both bitset & bitvector like methods
- Pascal methods respect immutability
- Chaining
- Lots of aliases
- Lots of output options
- ES6 binaries
- Made with bits of love!
Installation
npm install cell-bitset
Usage
const bs1 = BitSet // default length is 32 // the length of the underlying bitvector is automatically resized to 55 ; const bs2 = BitSet // create a bitvector with a specific size ; const bs3 = 7 54 23; // use an iterable to initialize the bitset. bs1; to;to; // will output the bitstringto; // The length of the underlying bitvector. The length of bs1 is automatically resizedto; // i.e. the number of flipped bits const bs4 = bs3; // use Pascal case Union to output a new bitset and leave bs3 unchanged to;to;
For more usage example see the unit tests.