X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Futils%2Farray.js;h=3d7f7ae4260c1852b6d8691082ce637813402c63;hb=e30523f27d5989903de6743a8b4f194a390d576c;hp=fae4ce911ee08534b3e2b5cfeeb600624c7b002a;hpb=9d58ef95e3affd799571838164f7c5bbfda11f64;p=vchess.git diff --git a/client/src/utils/array.js b/client/src/utils/array.js index fae4ce91..3d7f7ae4 100644 --- a/client/src/utils/array.js +++ b/client/src/utils/array.js @@ -1,32 +1,26 @@ // Remove item(s) in array (if present) -export const ArrayFun = -{ - remove: function(arr, rfun, all) - { +export const ArrayFun = { + + remove: function(arr, rfun, all) { const index = arr.findIndex(rfun); - if (index >= 0) - { + if (index >= 0) { arr.splice(index, 1); - if (!!all) - { + if (!!all) { // Reverse loop because of the splice below - for (let i=arr.length-1; i>=index; i--) - { - if (rfun(arr[i])) - arr.splice(i, 1); + for (let i = arr.length - 1; i >= index; i--) { + if (rfun(arr[i])) arr.splice(i, 1); } } } }, // Double array intialization - init: function(size1, size2, initElem) - { - return [...Array(size1)].map(e => Array(size2).fill(initElem)); + init: function(size1, size2, initElem) { + return [...Array(size1)].map(() => Array(size2).fill(initElem)); }, - range: function(max) - { + range: function(max) { return [...Array(max).keys()]; - }, + } + };