Total Complexity | 7 |
Complexity/F | 1.17 |
Lines of Code | 40 |
Function Count | 6 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | const converter = { |
||
2 | // convert list of object to an array |
||
3 | O2A: function(data){ |
||
4 | const converted = [] |
||
5 | //LOOPING EACH CHILD AND PUSHING TO ARRAY |
||
6 | for (const [key, value] of Object.entries(data.val())) { |
||
7 | value['object_key'] = key; |
||
8 | converted.push(value); |
||
9 | } |
||
10 | return converted; |
||
11 | }, |
||
12 | |||
13 | // Reverse array supplied |
||
14 | ReverseO2A: function(data){ |
||
15 | return data.reverse(); |
||
16 | }, |
||
17 | |||
18 | // Return the first Item in the array |
||
19 | FirstO2A : function(data){ |
||
20 | return data[0]; |
||
21 | }, |
||
22 | |||
23 | // Return the last Item in the array |
||
24 | LastO2A : function(data){ |
||
25 | return data.slice(-1)[0]; |
||
26 | }, |
||
27 | |||
28 | // Return N number of items in array |
||
29 | GetNO2A: function(data, number){ |
||
30 | return data.slice(0, number); |
||
31 | }, |
||
32 | |||
33 | // get total count of data in array |
||
34 | CountO2A:function(data){ |
||
35 | return data.length |
||
36 | } |
||
37 | |||
38 | } |
||
39 | |||
40 | export default converter; |