3d7f7ae4260c1852b6d8691082ce637813402c63
1 // Remove item(s) in array (if present)
2 export const ArrayFun
= {
4 remove: function(arr
, rfun
, all
) {
5 const index
= arr
.findIndex(rfun
);
9 // Reverse loop because of the splice below
10 for (let i
= arr
.length
- 1; i
>= index
; i
--) {
11 if (rfun(arr
[i
])) arr
.splice(i
, 1);
17 // Double array intialization
18 init: function(size1
, size2
, initElem
) {
19 return [...Array(size1
)].map(() => Array(size2
).fill(initElem
));
22 range: function(max
) {
23 return [...Array(max
).keys()];