Constructor
new BinaryData(data, precision)
Creates a new BinaryData object
Parameters:
| Name | Type | Description |
|---|---|---|
data |
decimal | hexString | binaryString | binaryArray | |
precision |
number |
Methods
and(data) → {string|undefined}
AND method returns a 1 in each bit position for which the corresponding bits (e.g. from the input data) of both are 1s.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
decimal | hexString | binaryString | binaryArray |
Returns:
- Type
- string | undefined
get() → {binaryString|undefined}
Returns the binaryString reprsentation of the data stored within the BinaryData instance.
Returns:
- Type
- binaryString | undefined
getArray() → {binaryArray|undefined}
Returns a duplicated version of the internal binaryArray.
Returns:
- Type
- binaryArray | undefined
getConversionType() → {string}
Returns the internal detection routine used when converting input data, represented as a string. It can be one of the following 5 values:
- 'decimal' :
decimal - 'hexString' :
hexString - 'binaryString' :
binaryString - 'binaryArray' :
binaryArray - 'error' : The data type could not be detected OR the conversion failed.
Returns:
- Type
- string
getDecimal() → {decimal|undefined}
Returns the decimal value of the data stored within the BinaryData instance.
Returns:
- Type
- decimal | undefined
getHex(removePrefixopt) → {hexString|undefined}
Returns the hexString reprsentation of the data stored within the BinaryData instance.
This can be with or without the hexadecimal string prefix of 0x.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
removePrefix |
boolean |
<optional> |
false |
Returns:
- Type
- hexString | undefined
getLength() → {number}
Returns the bit length of the value stored
Returns:
- Type
- number
getPrecision() → {number}
Returns the bit length of the value stored
Returns:
- Type
- number
getRaw() → {decimal|hexString|binaryString|binaryArray}
Returns the raw data that was passed in when the instance was created OR when the set method was called.
Returns:
- Type
- decimal | hexString | binaryString | binaryArray
getString() → {binaryString|undefined}
Returns the binaryString reprsentation of the data stored within the BinaryData instance.
Returns:
- Type
- binaryString | undefined
leftAdd(data) → {string|undefined}
Add bit values to the left of the binary data.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
decimal | hexString | binaryString | binaryArray |
Returns:
- Type
- string | undefined
leftShift(offset) → {string|undefined}
Shifts the internal binary data a specified number of bits to the left, within the precision of the BinaryData instance. Excess bits shifted off to the left are discarded. Zero bits are shifted in from the right.
Parameters:
| Name | Type | Description |
|---|---|---|
offset |
number |
Returns:
- Type
- string | undefined
not() → {string|undefined}
NOT method inverts the bits wihtin the internal binaryArray.
Returns:
- Type
- string | undefined
or(data) → {string|undefined}
OR method returns a 1 in each bit position for which the corresponding bits (e.g. from the input data) of either or both are 1s.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
decimal | hexString | binaryString | binaryArray |
Returns:
- Type
- string | undefined
rightAdd(data) → {string|undefined}
Add bit values to the right of the binary data.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
decimal | hexString | binaryString | binaryArray |
Returns:
- Type
- string | undefined
rightShift(offset) → {string|undefined}
Shifts the internal binary data a specified number of bits to the right, within the precision of the BinaryData instance. Excess bits shifted off to the right are discarded. Zero bits are shifted in from the left.
Parameters:
| Name | Type | Description |
|---|---|---|
offset |
number |
Returns:
- Type
- string | undefined
set(data, precisionopt) → {boolean}
TBA
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
data |
decimal | hexString | binaryString | binaryArray | ||
precision |
number |
<optional> |
Returns:
- Type
- boolean
setBit(index, value) → {string|undefined}
Manually replace the value of a single bit within the existing internal binaryArray at an
index from 0 to getPrecision() - 1.
Parameters:
| Name | Type | Description |
|---|---|---|
index |
number | |
value |
boolean |
Returns:
- Type
- string | undefined
xor(data) → {string|undefined}
XOR method returns a 1 in each bit position for which the corresponding bits (e.g. from the input data) of either but not both are 1s.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
decimal | hexString | binaryString | binaryArray |
Returns:
- Type
- string | undefined