MCPcopy Create free account
hub / github.com/scriptscat/scriptcat / base64ToBlob

Function base64ToBlob

src/pkg/utils/utils.ts:393–403  ·  view source on GitHub ↗
(dataURI: string)

Source from the content-addressed store, hash-verified

391*/
392
393export function base64ToBlob(dataURI: string) {
394 const mimeString = dataURI.split(",")[0].split(":")[1].split(";")[0];
395 const byteString = atob(dataURI.split(",")[1]);
396 const arrayBuffer = new ArrayBuffer(byteString.length);
397 const intArray = new Uint8Array(arrayBuffer);
398
399 for (let i = 0; i < byteString.length; i += 1) {
400 intArray[i] = byteString.charCodeAt(i);
401 }
402 return new Blob([intArray], { type: mimeString });
403}
404
405export function strToBase64(str: string): string {
406 return btoa(

Callers 3

renderFunction · 0.90
writeResourceMethod · 0.90
GM_getResourceURLMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected