Completed
Push — master ( f9440e...222018 )
by Pieter Epeüs
15s queued 10s
created

intersect.js ➔ intersect   A

Complexity

Conditions 5

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 17
rs 9.3333
c 0
b 0
f 0
cc 5
1
module.exports = 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