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 ( df9d3f...06b532 )
by Benjamin
01:27
created

src/util/fire.js   A

Complexity

Total Complexity 7
Complexity/F 3.5

Size

Lines of Code 6
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 0
wmc 7
c 2
b 0
f 0
nc 1
mnd 1
bc 1
fnc 2
dl 0
loc 6
rs 10
bpm 0.5
cpm 3.5
noi 0
1
export const fire = (name, events, scope, ...args) => {
2
    args = args.map(a => a && a.toJS ? a.toJS() : a);
3
    return events && name && typeof events[name] === 'function'
4
        ? events[name].apply(scope, args)
5
        : undefined;
6
};
7
8
export const fireEvent = (
9
    name,
10
    events,
11
    context = {},
12
    browserEvent
13
) => {
14
15
    if (!events || typeof events[name] !== 'function') {
16
        return;
17
    }
18
19
    const dynamicArgs = Object.keys(context)
20
        .reduce((prev, k) => {
21
            prev[k] = normalize(context[k]);
22
            return prev;
23
        }, {});
24
25
    // apply dynamic arguments
26
    // but these vals will always be represented
27
    return events[name]({
28
        ...dynamicArgs,
29
        editor: normalize(context.editor),
30
        events,
31
        isSelected: normalize(context.isSelected),
32
        row: normalize(context.row),
33
        rowId: normalize(context.rowId),
34
        rowIndex: normalize(context.rowIndex)
35
    }, browserEvent);
36
37
};
38
39
export const normalize = v => v && v.toJS
40
    ? v.toJS()
41
    : v;
42