GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 6efc01...f24beb )
by Benjamin
33s
created

findTreeNode.js ➔ ???   C

Complexity

Conditions 7
Paths 2

Size

Total Lines 32

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 7
c 1
b 0
f 0
nc 2
dl 0
loc 32
rs 6.7272
nop 4

1 Function

Rating   Name   Duplication   Size   Complexity  
A findTreeNode.js ➔ ... ➔ ??? 0 1 1
1
export const findTreeNode = (
2
    treeData,
3
    path,
4
    childIdentifier = 'children',
5
    rootIdentifier = 'root'
6
) => {
7
    path = [...path];
8
    const lookingFor = path[path.length - 1];
9
    let node = treeData[rootIdentifier];
10
11
    const firstId = path.shift();
12
13
    if (node.id === firstId) {
14
15
        while (path.length > 0 && node) {
16
17
            if (node
18
                && node.id !== lookingFor
19
                && node[childIdentifier]) {
20
21
                const nextId = path.shift();
22
                node = node[childIdentifier].find(n => n.id === nextId);
23
            }
24
25
            else {
26
                node = null;
27
            }
28
        }
29
    }
30
31
    return node;
32
};
33