Pinafore-Web-Client-Frontend/routes/_utils/decodeImage.js

11 lines
208 B
JavaScript
Raw Normal View History

2018-09-01 01:35:26 +02:00
export function decodeImage (img) {
if (typeof img.decode === 'function') {
return img.decode()
}
return new Promise((resolve, reject) => {
img.onload = resolve
img.onerror = reject
})
}