From 1f6445271615eccdc7483327f8557286c31fcb91 Mon Sep 17 00:00:00 2001 From: Igor Wessel Date: Mon, 6 May 2024 07:46:42 -0300 Subject: [PATCH] feat(utils): create a standard edge id function --- packages/mermaid/src/utils.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/mermaid/src/utils.ts b/packages/mermaid/src/utils.ts index 06aca5ab2..99283f359 100644 --- a/packages/mermaid/src/utils.ts +++ b/packages/mermaid/src/utils.ts @@ -929,3 +929,19 @@ export const decodeEntities = function (text: string): string { export const isString = (value: unknown): value is string => { return typeof value === 'string'; }; + +export const getEdgeId = ( + from: string, + to: string, + { + counter = 0, + prefix, + suffix, + }: { + counter?: number; + prefix?: string; + suffix?: string; + } +) => { + return `${prefix ? `${prefix}_` : ''}${from}_${to}_${counter}${suffix ? `_${suffix}` : ''}`; +};