Skip to content

Commit

Permalink
feat(utils): create a standard edge id function
Browse files Browse the repository at this point in the history
  • Loading branch information
igorwessel committed May 6, 2024
1 parent 9986b02 commit 1f64452
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/mermaid/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}` : ''}`;
};

0 comments on commit 1f64452

Please sign in to comment.