Methods
bitArrayToNumber
(static) bitArrayToNumber(inputBitArray): NumberTurns a bit array into a base-10 number
Parameters
Name | Type | Description |
---|---|---|
inputBitArray
|
Array.<Number> | a bit array only containing the numbers 0 and 1 |
Returns
result The number representation
Number
Example
// returns 25
RFUtil.bitArrayToNumber([0, 1, 1, 0, 0, 1]);
bitArrayToString
(static) bitArrayToString(inputBitArray): String|ErrorTurns a bit array into a bit string
Parameters
Name | Type | Description |
---|---|---|
inputBitArray
|
Array.<Number> | a bit array only containing numbers |
Returns
result The bitString
String
|
Error
Example
// returns '011201'
RFUtil.bitArrayToString([0, 1, 1, 2, 0, 1]);
bitStringToBitArray
(static) bitStringToBitArray(inputBitString): Array.<Number>|ErrorTurns a bit string into a bit array
Parameters
Name | Type | Description |
---|---|---|
inputBitString
|
String | a bit string only containing numbers |
Returns
result The bitArray
Array.<Number>
|
Error
Example
// returns [0, 1, 1, 2, 0, 1]
RFUtil.bitStringToBitArray('011201');
deepEqual
(static) deepEqual(a, b): booleanParameters
Name | Type | Description |
---|---|---|
a
|
||
b
|
Returns
boolean
generateRandomBitString
(static) generateRandomBitString(length): Array.<Number>Generates a random base-2 bit array
Parameters
Name | Type | Description |
---|---|---|
length
|
Number | the length that the result array should have (e.g. 8 bits) |
Returns
result The bitArray
Array.<Number>
Example
// returns [0, 1, 1, 0, 0, 1]
RFUtil.generateRandomBitString(6);
generateUUIDv4
(static) generateUUIDv4(): StringGenerates an UUID v4 String
Returns
uuid v4
String
numberToBitArray
(static) numberToBitArray(inputNumber, length): Array.<Number>Turns a number into a bit array
Parameters
Name | Type | Description |
---|---|---|
inputNumber
|
Number | the number to turn into a base-2 bit array |
length
|
Number | the length that the result array should have (e.g. 8 bits) |
Returns
result The bitArray or a error object when invalid input is given
Array.<Number>
Example
// returns [0, 1, 1, 0, 0, 1]
RFUtil.numberToBitArray(25, 6);