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

loadImages #2

Open
rjpgt opened this issue Mar 30, 2024 · 0 comments
Open

loadImages #2

rjpgt opened this issue Mar 30, 2024 · 0 comments

Comments

@rjpgt
Copy link

rjpgt commented Mar 30, 2024

Again, this is not important and perhaps you had wanted to keep it simple, but can't loadImages be made more concurrent if written this way:

export async function loadImages(collection) {
  const img_keys = Object.keys(collection);
  const img_paths = Object.values(collection);
  const img_promises = img_paths.map((img_path) => loadImage(img_path));
  const imgs = await Promise.all(img_promises);
  const img_entries = imgs.map((img, i) => [img_keys[i], img]);
  return Object.fromEntries(img_entries);
}
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

1 participant