pinafore/routes/_utils/decodeImage.js

11 lines
208 B
JavaScript
Raw Normal View History

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