Initial Commit ...
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
//
|
||||
//#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,
|
||||
};
|
||||
Reference in New Issue
Block a user