Skip to content

Commit e7e34b7

Browse files
committed
Humanize it.
1 parent 0048d7f commit e7e34b7

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

index.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
/**
22
* Converts an integer to an array representing its binary form.
33
*
4-
* @param {number} number - The integer to convert.
4+
* @param {number} total - The integer to convert.
55
* @param {number} length - The length of the resulting binary array.
6-
* @returns {Array<boolean>} An array of booleans representing the binary form of the number.
6+
* @returns {Array<boolean>} An array of booleans representing the binary form of the total.
77
*/
8-
export function convert(total, length, output = []) {
8+
export function convert(total, length = 32, output = []) {
99
for (let i = 0; i < length; i++) output[i] = !!(total & (1 << i));
1010

1111
return output;
1212
}
1313

1414
/**
15-
* Performs a bitwise merge on an array of boolean arrays using either OR or AND operation.
16-
* Note: The input arrays cannot have more than 32 values due to JavaScript's limitation with bitwise operations.
15+
* Performs a bitwise merge on a nested array input, each child being an array of booleans, using either OR or AND operation.
16+
* Note: The nested arrays cannont have more then 32 boolean values due to JavaScript's limitation with bitwise operations.
1717
*
18-
* @param {Array<Array<boolean>>} arrays - An array of boolean arrays to be merged.
19-
* @param {boolean} or - Determines the type of bitwise operation to use. If true, uses OR; if false, uses AND.
18+
* @param {Array<Array<boolean>>} input - An array which holds arrays of the boolean values to be merged.
19+
* @param {boolean} or - Determines bitwise operation to use. If true, OR; if false, AND.
2020
* @returns {Array<boolean>} A boolean array representing the result of the bitwise merge operation.
2121
*/
22-
export function BAM(arrays = [], or = true) {
23-
if (!Array.isArray(arrays) || arrays.length === 0 || !arrays.every(arr => Array.isArray(arr))) {
22+
export function BAM(input = [], or = true) {
23+
if (!Array.isArray(input) || input.length === 0 || !input.every(arr => Array.isArray(arr))) {
2424
return [];
2525
}
2626

2727
const data = {
28-
length: arrays.reduce(
28+
length: input.reduce(
2929
(accumulator, currentValue) => {
3030
if (accumulator < currentValue.length) return currentValue.length;
3131
return accumulator;
@@ -49,11 +49,11 @@ export function BAM(arrays = [], or = true) {
4949
data.total = set.max;
5050
}
5151

52-
// Loop through the arrays and merge, if the value is 'complete' before all input merged, it will end.
53-
for (let i = 0; i < arrays.length; i++) {
52+
// Loop through the input and merge, if the value is 'complete' before all input merged, it will end.
53+
for (let i = 0; i < input.length; i++) {
5454
if ((data.total = data.calc(
5555
// Calculate a integer based on the input array, treating index and value like binary. [ false, true ] == 2 == 0 1
56-
arrays[i].reduce((total, value, index) => !!value * Math.pow(2, index) + total, 0)
56+
input[i].reduce((total, value, index) => !!value * Math.pow(2, index) + total, 0)
5757
)) === data.complete) break;
5858
}
5959

0 commit comments

Comments
 (0)