Total Complexity | 11 |
Complexity/F | 2.2 |
Lines of Code | 38 |
Function Count | 5 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | // utilities |
||
3 | export const noop = () => {} |
||
4 | |||
5 | export const cloneObj = function (obj) { |
||
6 | return Object.assign({}, obj) |
||
7 | } |
||
8 | |||
9 | export const mergeObjs = function () { |
||
10 | let values = [] |
||
11 | for (let i = 0; i < arguments.length; i++){ |
||
12 | values.push(arguments[i]) |
||
13 | } |
||
14 | return Object.assign(...(values.map(cloneObj))) |
||
15 | } |
||
16 | |||
17 | export const clickNode = function (node) { |
||
18 | if (document.createEvent) { |
||
19 | let evt = document.createEvent('MouseEvents'); |
||
20 | evt.initEvent('click', true, false); |
||
21 | node.dispatchEvent(evt); |
||
22 | } else if (document.createEventObject) { |
||
23 | node.fireEvent('onclick'); |
||
24 | } else if (typeof node.onclick === 'function') { |
||
25 | node.onclick(); |
||
26 | } |
||
27 | } |
||
28 | |||
29 | export const firstIndex = function (arr, search, prop) { |
||
30 | let i |
||
31 | let limit = arr.length |
||
32 | |||
33 | for(i=0; i < limit; i++){ |
||
34 | if(arr[i][prop] === search){ |
||
35 | return i |
||
36 | } |
||
37 | } |
||
38 | |||
39 | return -1 |
||
40 | } |