src/modules/diff.js   A
last analyzed

Complexity

Total Complexity 9
Complexity/F 1.13

Size

Lines of Code 37
Function Count 8

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 9
eloc 20
mnd 1
bc 1
fnc 8
dl 0
loc 37
ccs 13
cts 13
cp 1
rs 10
bpm 0.125
cpm 1.125
noi 0
c 0
b 0
f 0

6 Functions

Rating   Name   Duplication   Size   Complexity  
A Diff.differenceArrayB 0 9 3
A Diff.compare 0 3 1
A Diff.constructor 0 5 1
A Diff.differenceArray 0 5 2
A Diff.create 0 5 1
A diff.js ➔ diff 0 3 1
1
class Diff {
2
    constructor(currentArray, otherArray, total) {
3 2
        this.currentArray = currentArray;
4 2
        this.otherArray = otherArray;
5 2
        this.total = total;
6
    }
7
8
    get differenceArray() {
9 2
        return this.currentArray.filter(
10 6
            (value) => this.otherArray.indexOf(value) < 0
11
        );
12
    }
13
14
    get differenceArrayB() {
15 2
        if (!this.total) {
16 1
            return [];
17
        }
18
19 1
        return this.otherArray.filter(
20 3
            (value) => this.currentArray.indexOf(value) < 0
21
        );
22
    }
23
24
    get compare() {
25 2
        return this.differenceArray.concat(this.differenceArrayB);
26
    }
27
28
    static create(currentArray, otherArray, total) {
29 2
        const differ = new Diff(currentArray, otherArray, total);
30
31 2
        return differ.compare;
32
    }
33
}
34
35
export default function diff(currentArray, otherArray, total) {
36 2
    return Diff.create(currentArray, otherArray, total);
37
}
38