fregante/image-promise

Deprecate package

fregante opened this issue · 3 comments

After finishing #25, I decided this package doesn't make sense anymore because of a new API: image.decode()

- loadImage(url)
+ new Image(url)

- await loadImage(url)
+ await new Image(url).decode()

Any reason for this module to continue existing? Its utility is mainly around the ability to create images from strings and await them:

await loadImages([a,b,c])

But that's not a great API if one of the loading fails, you might want to implement your own retry mechanism or just ignore them. Instead the whole promise fails.

So should it just return an array and have you deal with them via Promise.allSettled()? At that point the advantage is minimal, and not really matching the package name.

- const images = loadImages([a,b,c])
+ const images = [a,b,c].map(url => new Image(url))

await Promise.allSettled(images)

Yep

await Object.assign(new Image(), {src: url}).decode()

Oh right. So weird that it accepts the size and not the source 🤷‍♂️