Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
677c8e3fe7 | |||
b6d5db4605 | |||
0f802e223e | |||
d5438aaaab |
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@push.rocks/smartunique",
|
||||
"version": "3.0.6",
|
||||
"version": "3.0.8",
|
||||
"private": false,
|
||||
"description": "make things unique",
|
||||
"main": "dist_ts/index.js",
|
||||
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartunique',
|
||||
version: '3.0.6',
|
||||
version: '3.0.8',
|
||||
description: 'make things unique'
|
||||
}
|
||||
|
12
ts/index.ts
12
ts/index.ts
@ -18,8 +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', 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);
|
||||
|
Reference in New Issue
Block a user