MCPcopy Create free account
hub / github.com/devforth/painterro / imgToDataURL

Function imgToDataURL

js/utils.js:147–164  ·  view source on GitHub ↗
(url, callback, failedCb)

Source from the content-addressed store, hash-verified

145}
146
147export function imgToDataURL(url, callback, failedCb) {
148 const xhr = new XMLHttpRequest();
149 xhr.onload = () => {
150 const reader = new FileReader();
151 reader.onloadend = () => {
152 callback(reader.result);
153 };
154 reader.readAsDataURL(xhr.response);
155 };
156 xhr.onerror = () => {
157 if (typeof failedCb === "function") {
158 failedCb();
159 }
160 };
161 xhr.open("GET", url);
162 xhr.responseType = "blob";
163 xhr.send();
164}
165
166export function logError(error) {
167 console.warn(`[Painterro] ${error}`);

Callers 1

handleOpenMethod · 0.90

Calls 1

openMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…