Files
xSaherElmClient/platforms/electron/modules/tools/x-uuid.tools.js
T
2026-04-17 17:04:44 +03:30

38 lines
777 B
JavaScript

//
//#region Imports ...
const uuid = require("uuid");
//#endregion
//
//#region Constants ...
const DEFAULT_NAMESPACE = "SaherElm IT Center";
//#endregion
/**
* generate a uniqu identifier ...
*
* @param {string} prefix the prefix of generated uuid ...
* @param {string} content the additional content which added to generated uuid ...
* @param {string} nameSpace the proposed name space for generating uuid ...
* @returns a unique universal uuid ...
*/
function generateUuid(
prefix,
content,
nameSpace = DEFAULT_NAMESPACE
) {
//
const uId = content ? uuid.v5(content, nameSpace) : uuid.v4();
const result = prefix ? `${prefix}_${uId}` : uId;
//
return result;
}
//
// Module Exports ...
module.exports = {
DEFAULT_NAMESPACE,
generateUuid,
};