| Conditions | 7 |
| Total Lines | 23 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 7 |
| Changes | 0 | ||
| 1 | export default function intersect(original, array, multi) { |
||
| 2 | 4 | return original.filter((value) => { |
|
| 3 | 12 | if (multi) { |
|
| 4 | 6 | const found = array |
|
| 5 | 12 | .map((item) => JSON.stringify(item)) |
|
| 6 | .reduce((accumulator, currentValue) => { |
||
| 7 | 12 | if (currentValue.indexOf(JSON.stringify(value)) >= 0) { |
|
| 8 | 8 | return accumulator + 1; |
|
| 9 | } |
||
| 10 | |||
| 11 | 4 | return accumulator; |
|
| 12 | }, 0); |
||
| 13 | |||
| 14 | 6 | return found === array.length; |
|
| 15 | } |
||
| 16 | |||
| 17 | 6 | return ( |
|
| 18 | array |
||
| 19 | 18 | .map((item) => JSON.stringify(item)) |
|
| 20 | .indexOf(JSON.stringify(value)) >= 0 |
||
| 21 | ); |
||
| 22 | }); |
||
| 23 | } |
||
| 24 |