mdn / interactive-examples

Home of the MDN live code editor interactive examples
Creative Commons Zero v1.0 Universal
726 stars 506 forks source link

WAT memory examples - fix await #2759

Closed hamishwillee closed 3 months ago

hamishwillee commented 4 months ago

This fixes two WASM examples for working for memory.

Specifically these are JavaScript files that use await to wait on a returned promise, but then chain off the result using then - there is no point doing both, so this removes the "then" and makes it await properly.

There are probably similar examples, but these are the ones I'm looking at for https://github.com/mdn/content/issues/32777

dipikabh commented 3 months ago

Hi @bsmth, I'm not as familiar with WASM memory. Since you've recently reviewed similar content and examples, could you help by taking a look at this PR as well? Thanks!

hamishwillee commented 3 months ago

This is actually a JavaScript async issue really. It makes no sense to await on a promise when you're going to handle the result in a then. Either you await and handle the result in the next line, or you don't await and you handle in a then call. Not both.

github-actions[bot] commented 3 months ago

Congratulations on your first merged pull request. 🎉 Thank you for your contribution! Did you know we have a project board with high-impact contribution opportunities? We look forward to your next contribution.