diff --git a/.gitignore b/.gitignore index c0579ae4a..70569aa59 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /data -.env \ No newline at end of file +.env +/node_modules \ No newline at end of file diff --git a/common/utils.js b/common/utils.js deleted file mode 100644 index a6f8d6847..000000000 --- a/common/utils.js +++ /dev/null @@ -1,34 +0,0 @@ - -function roundTo(num, to = 2) { - return +(Math.round(num + "e+" + to) + "e-" + to); -} - -const flatToNestedArray = ( - data, - config = { id: 'id', parentId: 'parent_id' } -) => { - const map = {}; - const nestedArray = []; - - data.forEach((item) => { - map[item[config.id]] = { ...item }; - map[item[config.id]].children = []; - }); - - data.forEach((item) => { - const parentItemId = item[config.parentId]; - - if (!item[config.parentId]) { - nestedArray.push(item); - } - if (parentItemId) { - map[parentItemId].children.push(item); - } - }); - return nestedArray; -}; - -export default { - roundTo, - flatToNestedArray, -}; \ No newline at end of file