UNPKG

typedash

Version:

modern, type-safe collection of utility functions

20 lines (19 loc) 574 B
//#region src/functions/uniqueId/uniqueId.ts /** * Implementation for all overloads. * @param prefix An optional prefix for the identifier. * @returns A unique identifier. */ function uniqueId(prefix = "") { return `${prefix}${generateUUID()}`; } function generateUUID() { if (typeof crypto === "object" && typeof crypto.randomUUID === "function") return crypto.randomUUID(); return pseudoRandomUUID(); } function pseudoRandomUUID() { return Math.random().toString(36).slice(2, 11); } //#endregion export { uniqueId as t }; //# sourceMappingURL=uniqueId-CI-2Wpjt.js.map