mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 13:06:31 +00:00
feat: add uid
This commit is contained in:
parent
246737906d
commit
4bb4886ddb
@ -1,12 +1,4 @@
|
|||||||
import deepmerge from 'deepmerge';
|
export * from './merge';
|
||||||
|
|
||||||
const overwriteMerge = (destinationArray, sourceArray, options) => sourceArray;
|
|
||||||
|
|
||||||
export function merge(obj1: any, obj2: any) {
|
|
||||||
return deepmerge(obj1, obj2, {
|
|
||||||
arrayMerge: overwriteMerge,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export * from './mixin';
|
export * from './mixin';
|
||||||
export * from './mixin/AsyncEmitter';
|
export * from './mixin/AsyncEmitter';
|
||||||
|
export * from './uid';
|
||||||
|
9
packages/utils/src/merge.ts
Normal file
9
packages/utils/src/merge.ts
Normal 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
10
packages/utils/src/uid.ts
Normal 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;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user