🔨 refactor(utils.ts): simplify snakeToSpaces function

🔨 refactor(utils.ts): simplify getConnectedNodes function
🔨 refactor(utils.ts): remove unused variable in groupByFamily function
The snakeToSpaces function has been simplified by removing the unnecessary variable declaration. The getConnectedNodes function has been simplified by removing the unnecessary variable declaration and returning the result directly. The groupedObj variable in the groupByFamily function is no longer used, so it has been removed.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-06-23 10:51:29 -03:00
commit 713d2f19e5

View file

@ -407,9 +407,7 @@ export function toFirstUpperCase(str: string) {
} }
export function snakeToSpaces(str: string) { export function snakeToSpaces(str: string) {
let result = str.split("_").join(" "); return str.split("_").join(" ");
return result;
} }
export function toNormalCase(str: string) { export function toNormalCase(str: string) {
@ -453,10 +451,7 @@ export function roundNumber(x: number, decimals: number) {
export function getConnectedNodes(edge: Edge, nodes: Array<Node>): Array<Node> { export function getConnectedNodes(edge: Edge, nodes: Array<Node>): Array<Node> {
const sourceId = edge.source; const sourceId = edge.source;
const targetId = edge.target; const targetId = edge.target;
const connectedNodes = nodes.filter( return nodes.filter((node) => node.id === targetId || node.id === sourceId);
(node) => node.id === targetId || node.id === sourceId
);
return connectedNodes;
} }
export function isValidConnection( export function isValidConnection(
@ -703,7 +698,7 @@ export function groupByFamily(data, baseClasses) {
return foundIndex === index; return foundIndex === index;
}); });
let groupedObj = groupedBy.reduce((result, item) => { return groupedBy.reduce((result, item) => {
const existingGroup = result.find((group) => group.family === item.family); const existingGroup = result.find((group) => group.family === item.family);
if (existingGroup) { if (existingGroup) {
@ -714,8 +709,6 @@ export function groupByFamily(data, baseClasses) {
return result; return result;
}, []); }, []);
return groupedObj;
} }
export function buildTweaks(flow) { export function buildTweaks(flow) {