From 713d2f19e5da79a38acd0cb6d07370d1e424cd7a Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 23 Jun 2023 10:51:29 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20refactor(utils.ts):=20simplify?= =?UTF-8?q?=20snakeToSpaces=20function=20=F0=9F=94=A8=20refactor(utils.ts)?= =?UTF-8?q?:=20simplify=20getConnectedNodes=20function=20=F0=9F=94=A8=20re?= =?UTF-8?q?factor(utils.ts):=20remove=20unused=20variable=20in=20groupByFa?= =?UTF-8?q?mily=20function=20The=20snakeToSpaces=20function=20has=20been?= =?UTF-8?q?=20simplified=20by=20removing=20the=20unnecessary=20variable=20?= =?UTF-8?q?declaration.=20The=20getConnectedNodes=20function=20has=20been?= =?UTF-8?q?=20simplified=20by=20removing=20the=20unnecessary=20variable=20?= =?UTF-8?q?declaration=20and=20returning=20the=20result=20directly.=20The?= =?UTF-8?q?=20groupedObj=20variable=20in=20the=20groupByFamily=20function?= =?UTF-8?q?=20is=20no=20longer=20used,=20so=20it=20has=20been=20removed.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/src/utils.ts | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/frontend/src/utils.ts b/src/frontend/src/utils.ts index d22245a31..d4c5d0190 100644 --- a/src/frontend/src/utils.ts +++ b/src/frontend/src/utils.ts @@ -407,9 +407,7 @@ export function toFirstUpperCase(str: string) { } export function snakeToSpaces(str: string) { - let result = str.split("_").join(" "); - - return result; + return str.split("_").join(" "); } export function toNormalCase(str: string) { @@ -453,10 +451,7 @@ export function roundNumber(x: number, decimals: number) { export function getConnectedNodes(edge: Edge, nodes: Array): Array { const sourceId = edge.source; const targetId = edge.target; - const connectedNodes = nodes.filter( - (node) => node.id === targetId || node.id === sourceId - ); - return connectedNodes; + return nodes.filter((node) => node.id === targetId || node.id === sourceId); } export function isValidConnection( @@ -703,7 +698,7 @@ export function groupByFamily(data, baseClasses) { return foundIndex === index; }); - let groupedObj = groupedBy.reduce((result, item) => { + return groupedBy.reduce((result, item) => { const existingGroup = result.find((group) => group.family === item.family); if (existingGroup) { @@ -714,8 +709,6 @@ export function groupByFamily(data, baseClasses) { return result; }, []); - - return groupedObj; } export function buildTweaks(flow) {