Lightweight BitArray implementation written in javascript.
npm install bit-vec

!npm
A lightweight, performant and well documented BitArray/BitVector implementation written in javascript.
npm install bit-vec --save.After installing
``js
import BitVector from 'bit-vec';
const bitVec = new BitVector(8);
`
Example Usage:
`js
import BitVector from 'bit-vec';
const bitVec = new BitVector(8);
bitVec.set(5, 1);
bitVec.test(5); // true
bitVec.flip(5);
bitVec.test(5); // false
// Chaining.
bitVec
.set(5)
.set(3)
.set(1)
.clearRange(0, 4)
.test(3); // false
`
Below is a condensed form of the documentation, each is a function that can be found on the BitVector object, called like so.
`js`
const bitVec = new BitVector(42);
bitVec.test(34); // false
bitVec.set(34, 1);
bitVec.test(34); // true
| Method | Parameters | Return |
| ----------- | -------- | ------ |
| .get(index) | index:Number | Number, 1 if set, 0 if not. |index:Number
| .set(index) | | Returns this with the bit set. |index:Number
| .test(index) | | Returns Boolean true if index is set, false otherwise . |index:Number
| .clear(index) | | Returns this with cleared bit. |index:Number
| .flip(index) | | Returns this with flipper bit. |None
| .count() | | Returns Number number of indices currently set to 1. |begin:Number, end:Number, value:Number
| .setRange(begin, end, value = 1) | | Returns this with bits set.|begin:Number, end:Number
| .clearRange(begin, end) | | Returns this with bits cleared. |bitVec:BitVector
| .equals(bitVec) | | Returns Boolean true if the two bit vectors are equal, false otherwise. |bitVec:BitVector
| .notEquals(bitVec) | | Returns Boolean true if the two bit vectors are different, false otherwise. |bitVec:BitVector
| .or(bitVec) | | Returns new BitVector object with the result of the operation.|bitVec:BitVector
| .xor(bitVec) | | Returns new BitVector object with the result of the operation.|bitVec:BitVector
| .and(bitVec) | | Returns new BitVector object with the result of the operation.|None
| .not() | | Returns new BitVector object with the result of the operation. |None
| .invert() | | Returns this with updated array. |bitVec:BitVector
| .orEqual(bitVec) | | Returns new BitVector object with the result of the operation.|bitVec:BitVector
| .xorEqual(bitVec) | | Returns new BitVector object with the result of the operation.|bitVec:BitVector
| .andEqual(bitVec) | | Returns new BitVector object with the result of the operation.|None
| .notEqual() | | Returns new BitVector object with the result of the operation. |None
| .isEmpty() | |Returns Boolean true if the bit vector has no set bits, false otherwise. |
---
Performs a get operation on the given index, retrieving the stored value (0 or 1).
##### Parameters
* index -> Number for index: 0 <= index < bitVec.bits.
##### Returns
Number, 1 if set, 0 otherwise.
##### Example
`js
bitVec.get(52); // 0
`---
$3
bitVec.set(index)Performs a set operation on the given index, setting the value to either 0 or 1.
##### Parameters
* index -> Number for index: 0 <= index < bitVec.bits.
* value -> Number, 0 or 1, defaults to 1.
##### Returns
Returns
BitVector for chaining with the bit set.##### Example
`js
bitVec.set(52); // BitVector
`---
$3
bitVec.test(index)Tests whether the given index is set to 1.
##### Parameters
* index -> Number for index: 0 <= index < bitVec.bits.
##### Returns
Returns Boolean
true if index is set, false otherwise .##### Example
`js
bitVec.set(52, 1);
bitVec.test(52); // true
`---
$3
bitVec.clear(index)Clears the bit at the given index.
##### Parameters
* index -> Number for index: 0 <= index < bitVec.bits.
##### Returns
Returns
BitVector for chaining with the bit cleared.##### Example
`js
bitVec.set(52, 1);
bitVec.test(52); // true
`---
$3
bitVec.flip(index)Flips the bit at the given index.
##### Parameters
* index -> Number for index: 0 <= index < bitVec.bits.
##### Returns
Returns
BitVector for chaining with the bit cleared.##### Example
`js
bitVec.flip(52);
`---
$3
bitVec.count()Counts the number of set bits in the bit vector.
##### Parameters
* None
##### Returns
Returns
Number number of indices currently set to 1.##### Example
`js
bitVec.count();
`---
$3
bitVec.setRange(begin, end, value = 1)Sets a range of bits from begin to end.
##### Parameters
* begin -> Number for index: 0 <= index < bitVec.bits.
* end -> Number for index: 0 <= index < bitVec.bits.
* value -> The value to set the index to (0 or 1).
##### Returns
Returns
this with bits set.##### Example
`js
bitVec.setRange(2, 6);
`---
$3
bitVec.clearRange(begin, end)Clears a range of bits from begin to end.
##### Parameters
* begin -> Number for index: 0 <= index < bitVec.bits.
* end -> Number for index: 0 <= index < bitVec.bits.
##### Returns
Returns
this with bits cleared.##### Example
`js
bitVec.clearRange(2, 6);
`---
$3
bitVec.equals(otherBitVec)Determines if two bit vectors are equal.
##### Parameters
* bitVec -> BitVector, instance of BitVector class.
##### Returns
Returns Boolean
true if the two bit vectors are equal, false otherwise.##### Example
`js
bitVec.equals(otherBitVec);
`---
$3
bitVec.notEquals(otherBitVec)Determines if two bit vectors are not equal.
##### Parameters
* bitVec -> BitVector, instance of BitVector class.
##### Returns
Returns Boolean
true if the two bit vectors are equal, false otherwise.##### Example
`js
bitVec.notEquals(otherBitVec);
`---
$3
bitVec.or(otherBitVec)Performs the bitwise or operation between two BitVectors and returns the result as a
new BitVector object.
##### Parameters
* bitVec -> BitVector, instance of BitVector class.
##### Returns
Returns new
BitVector object with the result of the operation.##### Example
`js
bitVec.or(otherBitVec);
`---
$3
bitVec.xor(otherBitVec)Performs the bitwise xor operation between two BitVectors and returns the result as a
new BitVector object.
##### Parameters
* bitVec -> BitVector, instance of BitVector class.
##### Returns
Returns new
BitVector object with the result of the operation.##### Example
`js
bitVec.xor(otherBitVec);
`---
$3
bitVec.and(otherBitVec)Performs the bitwise and operation between two BitVectors and returns the result as a
new BitVector object.
##### Parameters
* bitVec -> BitVector, instance of BitVector class.
##### Returns
Returns new
BitVector object with the result of the operation.##### Example
`js
bitVec.and(otherBitVec);
`---
$3
bitVec.not()Performs the bitwise not operation between two BitVectors and returns the result as a
new BitVector object.
##### Parameters
* None
##### Returns
Returns new
BitVector object with the result of the operation.##### Example
`js
bitVec.not();
`---
$3
bitVec.invert()Inverts this BitVector, alias of .not().
##### Parameters
* None
##### Returns
Returns new
BitVector object with the result of the operation.##### Example
`js
bitVec.invert();
`---
$3
bitVec.orEqual(otherBitVec)Performs the bitwise or operation between two BitVectors and assigns the result to
this BitVector.
##### Parameters
* bitVec -> BitVector, instance of BitVector class.
##### Returns
Returns
this for chaining with the bits set.##### Example
`js
bitVec.orEqual(otherBitVec);
`---
$3
bitVec.xorEqual(otherBitVec)Performs the bitwise xor operation between two BitVectors and assigns the result to
this BitVector.
##### Parameters
* bitVec -> BitVector, instance of BitVector class.
##### Returns
Returns
this for chaining with the bits set.##### Example
`js
bitVec.xorEqual(otherBitVec);
`---
$3
bitVec.andEqual(otherBitVec)Performs the bitwise and operation between two BitVectors and assigns the result to
this BitVector.
##### Parameters
* bitVec -> BitVector, instance of BitVector class.
##### Returns
Returns
this for chaining with the bits set.##### Example
`js
bitVec.andEqual(otherBitVec);
`---
$3
bitVec.notEqual(otherBitVec)Performs the bitwise not operation between two BitVectors and assigns the result to
this BitVector.
##### Parameters
* bitVec -> BitVector, instance of BitVector class.
##### Returns
Returns
this for chaining with the bits set.##### Example
`js
bitVec.notEqual(otherBitVec);
`---
$3
bitVec.isEmpty()Tests whether this BitVector has any set bits.
##### Parameters
* bitVec -> BitVector, instance of BitVector class.
##### Returns
Returns Boolean
true if the bit vector has no set bits, false otherwise.##### Example
`js
bitVec.isEmpty();
``---