basically working onedrive

This commit is contained in:
fyears
2021-12-29 00:35:46 +08:00
parent f3e6bc2fdd
commit 6552fd32d1
9 changed files with 1088 additions and 17 deletions
+25
View File
@@ -163,3 +163,28 @@ export const extractSvgSub = (x: string, subEl: string = "rect") => {
svg.setAttribute("viewbox", "0 0 10 10");
return svg.innerHTML;
};
/**
* https://stackoverflow.com/questions/18230217
* @param min
* @param max
* @returns
*/
export const getRandomIntInclusive = (min: number, max: number) => {
const randomBuffer = new Uint32Array(1);
window.crypto.getRandomValues(randomBuffer);
let randomNumber = randomBuffer[0] / (0xffffffff + 1);
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(randomNumber * (max - min + 1)) + min;
};
/**
* Random buffer
* @param byteLength
* @returns
*/
export const getRandomArrayBuffer = (byteLength: number) => {
const k = window.crypto.getRandomValues(new Uint8Array(byteLength));
return bufferToArrayBuffer(k);
};