1
0
mirror of https://github.com/nolanlawson/pinafore synced 2024-12-11 17:59:20 +01:00
Pinafore-Web-Client-Frontend/tests/blobUtils.js
greenkeeper[bot] 8dbc1b0503 Update standard to the latest version 🚀 (#519)
* chore(package): update standard to version 12.0.0

* package lock update

* fix eslint
2018-08-29 21:42:57 -07:00

16 lines
431 B
JavaScript

export function base64StringToBlob (base64, type) {
function binaryStringToArrayBuffer (binary) {
let length = binary.length
let buf = new ArrayBuffer(length)
let arr = new Uint8Array(buf)
let i = -1
while (++i < length) {
arr[i] = binary.charCodeAt(i)
}
return buf
}
let parts = [binaryStringToArrayBuffer(atob(base64))]
return type ? new Blob(parts, { type: type }) : new Blob(parts)
}