feat: add uid

This commit is contained in:
chenos 2022-01-08 18:02:42 +08:00
parent 246737906d
commit 4bb4886ddb
3 changed files with 21 additions and 10 deletions

View File

@ -1,12 +1,4 @@
import deepmerge from 'deepmerge';
const overwriteMerge = (destinationArray, sourceArray, options) => sourceArray;
export function merge(obj1: any, obj2: any) {
return deepmerge(obj1, obj2, {
arrayMerge: overwriteMerge,
});
}
export * from './merge';
export * from './mixin';
export * from './mixin/AsyncEmitter';
export * from './uid';

View File

@ -0,0 +1,9 @@
import deepmerge from 'deepmerge';
const overwriteMerge = (destinationArray, sourceArray, options) => sourceArray;
export function merge(obj1: any, obj2: any) {
return deepmerge(obj1, obj2, {
arrayMerge: overwriteMerge,
});
}

10
packages/utils/src/uid.ts Normal file
View File

@ -0,0 +1,10 @@
let IDX = 36,
HEX = '';
while (IDX--) HEX += IDX.toString(36);
export function uid(len?: number) {
let str = '',
num = len || 11;
while (num--) str += HEX[(Math.random() * 36) | 0];
return str;
}