mirror of
https://github.com/drawdb-io/drawdb.git
synced 2026-02-12 02:00:40 +08:00
Declutter utils
This commit is contained in:
18
src/utils/utils.js
Normal file
18
src/utils/utils.js
Normal file
@@ -0,0 +1,18 @@
|
||||
function dataURItoBlob(dataUrl) {
|
||||
const byteString = atob(dataUrl.split(",")[1]);
|
||||
const mimeString = dataUrl.split(",")[0].split(":")[1].split(";")[0];
|
||||
const arrayBuffer = new ArrayBuffer(byteString.length);
|
||||
const intArray = new Uint8Array(arrayBuffer);
|
||||
|
||||
for (let i = 0; i < byteString.length; i++) {
|
||||
intArray[i] = byteString.charCodeAt(i);
|
||||
}
|
||||
|
||||
return new Blob([intArray], { type: mimeString });
|
||||
}
|
||||
|
||||
function arrayIsEqual(arr1, arr2) {
|
||||
return JSON.stringify(arr1) === JSON.stringify(arr2);
|
||||
}
|
||||
|
||||
export { dataURItoBlob, arrayIsEqual };
|
||||
Reference in New Issue
Block a user