Skip to content

Commit

Permalink
feat: creat uuidv4 util function (#187)
Browse files Browse the repository at this point in the history
Fix #187
  • Loading branch information
soonki-98 committed Oct 8, 2022
1 parent 11a6ef8 commit 92f9f9f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib/common/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as uuidv4 } from './uuidv4';
9 changes: 9 additions & 0 deletions src/lib/common/utils/uuidv4.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function uuidv4() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
const random = (Math.random() * 16) | 0;
const result = c == 'x' ? random : (random & 0x3) | 0x8;
return result.toString(16);
});
}

export default uuidv4;

0 comments on commit 92f9f9f

Please sign in to comment.