diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 71ed7dd..c3ad61e 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@push.rocks/smartunique', - version: '3.0.7', + version: '3.0.8', description: 'make things unique' } diff --git a/ts/index.ts b/ts/index.ts index be390fc..dbb1c61 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -18,16 +18,16 @@ export const uuid5 = (customStringArg: string, namespaceArg = plugins.uuid.v5.DN return plugins.uuid.v5(customStringArg, namespaceArg); }; -export const uni = (prefix: string = 'uni') => { - return `${prefix}_${`xxxxxxxxxxxxxxxxxxxxxxxx`.replace(/[xy]/g, (c) => { +export const uni = (prefix: string = 'uni', lengthArg = 24) => { + return `${prefix}_${'x'.repeat(lengthArg).replace(/[xy]/g, (c) => { const r = (Math.random() * 16) | 0; const v = c === 'x' ? r : (r & 0x3) | 0x8; return v.toString(16); })}`; }; -export const uniSimple = (prefix: string = 'uni') => { - return `${prefix}${`xxxxxxxxxxxxxxxxxxxxxxxx`.replace(/[xy]/g, (c) => { +export const uniSimple = (prefix: string = 'uni', lengthArg = 8) => { + return `${prefix}${'x'.repeat(lengthArg).replace(/[xy]/g, (c) => { const r = (Math.random() * 16) | 0; const v = c === 'x' ? r : (r & 0x3) | 0x8; return v.toString(16);