basically working onedrive
This commit is contained in:
+25
@@ -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);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user