Passed
Pull Request — master (#30)
by Pieter Epeüs
01:35
created

src/modules/intersect.js   A

Complexity

Total Complexity 7
Complexity/F 2.33

Size

Lines of Code 24
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 13
mnd 4
bc 4
fnc 3
dl 0
loc 24
rs 10
bpm 1.3333
cpm 2.3333
noi 0
c 0
b 0
f 0
1
module.exports = function intersect(original, array, multi) {
2
    return original.filter((value) => {
3
        let found = 0;
4
5
        if (multi) {
6
            array.forEach((arrayValues) => {
7
                if (arrayValues.indexOf(value) >= 0) {
8
                    found += 1;
9
                }
10
            });
11
12
            if (found === array.length) {
13
                return true;
14
            }
15
            return false;
16
        }
17
18
        if (array.indexOf(value) >= 0) {
19
            return true;
20
        }
21
22
        return false;
23
    });
24
};
25