🌳
pt0/sharedF/genUuidF.mts
1import getUuidByString from 'uuid-by-string'
2import type { NoDashesUuid } from './idTypesF.mts'
4export function removeDashes(str: string): NoDashesUuid
5export function removeDashes(str: string | null | undefined): NoDashesUuid | null | undefined
6export function removeDashes(str: string | null | undefined): NoDashesUuid | null | undefined {
7 if (!str) return str as NoDashesUuid | null | undefined
8 return str.replace(/-/g, '') as NoDashesUuid
9}
11export const genUuid = (str: string): NoDashesUuid => {
12 if (Array.isArray(str)) {
13 str = str.join('-')
14 }
15 return removeDashes(getUuidByString(str))