Completed
Push — master ( b8c0d7...8cf4a8 )
by Pieter Epeüs
21s queued 10s
created

intersect.js ➔ intersect   B

Complexity

Conditions 7

Size

Total Lines 24
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 24
rs 8
c 0
b 0
f 0
cc 7
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