nest_scaffold/src/libs/utils/correlationId.ts
2023-02-26 22:00:26 +07:00

12 lines
390 B
TypeScript

export function createCorrelationId(length: number): string {
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let counter = 0;
let result: string = '';
const charactersLength = characters.length;
while (counter < length) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
counter += 1;
}
return result;
}