reorganize directory and file structure
This commit is contained in:
parent
1d826ea8d4
commit
48390b8556
99 changed files with 1155 additions and 1629 deletions
16
lib/util/random.js
Normal file
16
lib/util/random.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
// IMPURE
|
||||
export const genUUID = (len=16) => {
|
||||
const arr = crypto.getRandomValues(new Uint8Array(len));
|
||||
let result = "";
|
||||
for (let i=0; i<len; i++) {
|
||||
const unsignedByte = arr[i];
|
||||
if (unsignedByte < 16) {
|
||||
result += '0' + unsignedByte.toString(16);
|
||||
} else {
|
||||
result += unsignedByte.toString(16);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
console.log(genUUID())
|
||||
Loading…
Add table
Add a link
Reference in a new issue