Skip to content

Commit

Permalink
Make it so OVERLAP, [], [] results in True
Browse files Browse the repository at this point in the history
  • Loading branch information
justinchang91 committed Mar 21, 2024
1 parent a7c408e commit ebfad9d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/expression/comparison/__test__/unit/overlap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe('Expression - Comparison - Overlap', () => {
new Collection([new Value('1'), new Value('2')]),
true,
],
[new Collection([]), new Collection([]), true],
// Truthy - Bi-directional
[
new Collection([new Value(1), new Value(2), new Value(5)]),
Expand Down
4 changes: 4 additions & 0 deletions src/expression/comparison/overlap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export class Overlap extends Comparison {

const leftArray = left as (string | number)[]
const rightArray = right as (string | number)[]

if (leftArray.length === 0 && rightArray.length === 0) {
return true
}
return leftArray.some((element) => rightArray.includes(element))
}

Expand Down

0 comments on commit ebfad9d

Please sign in to comment.