(url, callback, failedCb)
| 145 | } |
| 146 | |
| 147 | export 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 | |
| 166 | export function logError(error) { |
| 167 | console.warn(`[Painterro] ${error}`); |
no test coverage detected
searching dependent graphs…