Passed
Push — main ( 6bd289...c1f636 )
by Pieter Epeüs
57s queued 12s
created

src/modules/intersect.js   A

Complexity

Total Complexity 5
Complexity/F 1.67

Size

Lines of Code 17
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 10
mnd 2
bc 2
fnc 3
dl 0
loc 17
rs 10
bpm 0.6666
cpm 1.6666
noi 0
c 0
b 0
f 0
1
export default function intersect(original, array, multi) {
2
    return original.filter((value) => {
3
        if (multi) {
4
            const found = array.reduce((accumulator, currentValue) => {
5
                if (currentValue.indexOf(value) >= 0) {
6
                    return accumulator + 1;
7
                }
8
9
                return accumulator;
10
            }, 0);
11
12
            return found === array.length;
13
        }
14
15
        return array.indexOf(value) >= 0;
16
    });
17
}
18