mirror of
https://github.com/nolanlawson/pinafore
synced 2024-12-08 16:25:25 +01:00
16 lines
439 B
JavaScript
16 lines
439 B
JavaScript
export function base64StringToBlob (base64, type) {
|
|
function binaryStringToArrayBuffer (binary) {
|
|
const length = binary.length
|
|
const buf = new ArrayBuffer(length)
|
|
const arr = new Uint8Array(buf)
|
|
let i = -1
|
|
while (++i < length) {
|
|
arr[i] = binary.charCodeAt(i)
|
|
}
|
|
return buf
|
|
}
|
|
|
|
const parts = [binaryStringToArrayBuffer(atob(base64))]
|
|
return type ? new Blob(parts, { type: type }) : new Blob(parts)
|
|
}
|