Skip to content

Commit 0048d7f

Browse files
committed
Add test for default error value which is now an empty array
1 parent f0acbb9 commit 0048d7f

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ export function convert(total, length, output = []) {
2020
* @returns {Array<boolean>} A boolean array representing the result of the bitwise merge operation.
2121
*/
2222
export function BAM(arrays = [], or = true) {
23-
if (!Array.isArray(arrays) || arrays.length === 0) return [];
23+
if (!Array.isArray(arrays) || arrays.length === 0 || !arrays.every(arr => Array.isArray(arr))) {
24+
return [];
25+
}
2426

2527
const data = {
2628
length: arrays.reduce(

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
"type": "git",
88
"url": "https://github.com/rgk/boolean-array-merge.git"
99
},
10+
"bugs": {
11+
"url": "https://github.com/rgk/boolean-array-merge/issues"
12+
},
1013
"scripts": {
1114
"test": "node ./test.js"
1215
},

test.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,17 @@ assert.deepStrictEqual(
8888
BAM(
8989
{}
9090
),
91-
false
91+
[ ]
92+
);
93+
94+
// Make sure it only accepts arrays nested.
95+
assert.deepStrictEqual(
96+
BAM(
97+
[
98+
[ true, false, true ], {}
99+
]
100+
),
101+
[ ]
92102
);
93103

94104
// Check if no value fails.

0 commit comments

Comments
 (0)