Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate package #27

Closed
fregante opened this issue Jun 10, 2024 · 3 comments
Closed

Deprecate package #27

fregante opened this issue Jun 10, 2024 · 3 comments

Comments

@fregante
Copy link
Owner

fregante commented Jun 10, 2024

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)
@fregante fregante mentioned this issue Jun 10, 2024
@fregante
Copy link
Owner Author

Yep

@fisker
Copy link

fisker commented Jun 11, 2024

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

@fregante
Copy link
Owner Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants