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