src/modules/intersect.js   A
last analyzed

Complexity

Total Complexity 5
Complexity/F 1.67

Size

Lines of Code 17
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
eloc 10
mnd 2
bc 2
fnc 3
dl 0
loc 17
ccs 8
cts 8
cp 1
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 2
    return original.filter((value) => {
3 6
        if (multi) {
4 3
            const found = array.reduce((accumulator, currentValue) => {
5 6
                if (currentValue.indexOf(value) >= 0) {
6 4
                    return accumulator + 1;
7
                }
8
9 2
                return accumulator;
10
            }, 0);
11
12 3
            return found === array.length;
13
        }
14
15 3
        return array.indexOf(value) >= 0;
16
    });
17
}
18