feat(utils): create a standard edge id function

This commit is contained in:
Igor Wessel 2024-05-06 07:46:42 -03:00
parent 9986b023d7
commit 1f64452716
1 changed files with 16 additions and 0 deletions

View File

@ -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}` : ''}`;
};