From 413293cc5984b3b4e8d694ce7d5871bd531538d2 Mon Sep 17 00:00:00 2001 From: elforjani13 <39470382+elforjani13@users.noreply.github.com> Date: Tue, 21 Sep 2021 19:19:28 +0200 Subject: [PATCH] fix: remove common/utils. --- .gitignore | 3 ++- common/utils.js | 34 ---------------------------------- 2 files changed, 2 insertions(+), 35 deletions(-) delete mode 100644 common/utils.js 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