Set value for a bit on position
unsigned integer value
Optional
on: boolean = falseOptional set true or false (default : false)
Set bit: false according to integer position Note: Starting from 1
unsigned integer value
Depending on the GIBBONS_ENCODE_FROM_TO_STRING environment variable if converts this
Gibbon to a string
or Buffer
Compare two gibbon instances on data contents
instance of a Gibbon
if instance (or contents) are the same
This method analyzes every bit value in this gibbon and creates the corresponding
position array where bits are logical true.
Which contains bit positions from this gibbon, which are logical set to true
// Initialize a Gibbon (2 bytes)
const gibbon = Gibbon.create(2);
// Pre set some bit positions
gibbon.setPosition(1)
.setPosition(2)
.setPosition(3)
.setPosition(4)
.setPosition(5)
.setPosition(6)
.setPosition(7)
.setPosition(8)
.setPosition(10);
gibbon.getPositionsArray(); // returns: [1, 2, 3, 4, 5, 6, 7, 8, 10]
Compare 2 gibbons and see if this gibbon shares all given bits
Compares all given positions
When one wants to check on bit positions outside the memory bounds (dataViewBounds),
method wil return early with false
.
containing signed integer values (representing bit positions)
true when all positions correspondent to the given indexes
// Initialize a gibbon with 2 bytes
const gibbon = Gibbon.create(2);
// Set 2 bit positions to logical '1'
gibbon.setPosition(1).setPosition(2);
gibbon.hasAllFromPositions([1, 2]); // true
Compare 2 gibbons and see if this gibbon has at least one bit alike
Compares the given positions
When any of the positions conforms to logical '1' (true), we return true
early.
When one wants to check on bit positions outside the memory bounds (dataViewBounds),
method wil return early with false
.
containing signed integer values (representing bit positions)
true when one of these positions correspond
// Initialize a gibbon with 2 bytes
const gibbon = Gibbon.create(2);
// Set 3 bit positions to logical '1'
gibbon.setPosition(1).setPosition(2).setPosition(10);
gibbon.hasAnyFromPositions([1, 9]); // true
Able to manipulate bits according to an array of signed integers
Array with integer values starting from 1.
// Set 2 bit positions to logical '1'
const gibbon = Gibbon.create(2);
gibbon.setAllFromPositions([1, 2]);
gibbon.hasAllFromPositions([1, 2]); // returns true
Set bit: true according to integer position in the Gibbon
Note: Starting from 1
unsigned integer value
Converts this Gibbon instance to a Buffer
Toggle bit value true => false, false => true
unsigned integer value
Convert the whole ArrayBuffer to a string
(Hint: Could be used to store a gibbon in persistent storage as a encoded string)
Able to manipulate bits according to an array of signed integers (opposite of setAllFromPositions)
Array with integer values starting from 1.
// Set 2 bit positions to logical '0'
const gibbon = Gibbon.create(2);
gibbon.unsetAllFromPositions([1, 2]);
gibbon.hasAllFromPositions([1, 2]); // returns false
gibbon.hasAllFromPositions([-1, -2]); // returns true
Static
createCreates a new empty Gibbon from a given byte size
Allocate this Gibbon with a unsigned integer value (size in bytes)
Static
decodeAccepts a string of Buffer to create a new Gibbon instance
Static
fromStatic
fromClass method to create a new Gibbon from a string
(Hint: Could be used to retrieve from persistent storage)
To be decoded to a Gibbon
A Gibbon
Param: arrayBuffer
allocate this Gibbon with some working memory