Socket
Socket
Sign inDemoInstall

esbuild-wasm

Package Overview
Dependencies
0
Maintainers
1
Versions
458
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    esbuild-wasm

The cross-platform WebAssembly binary for esbuild, a JavaScript bundler.


Version published
Maintainers
1
Install size
10.8 MB
Created

Changelog

Source

0.18.8

  • Implement transforming async generator functions (#2780)

    With this release, esbuild will now transform async generator functions into normal generator functions when the configured target environment doesn't support them. These functions behave similar to normal generator functions except that they use the Symbol.asyncIterator interface instead of the Symbol.iterator interface and the iteration methods return promises. Here's an example (helper functions are omitted):

    // Original code
    async function* foo() {
      yield Promise.resolve(1)
      await new Promise(r => setTimeout(r, 100))
      yield *[Promise.resolve(2)]
    }
    async function bar() {
      for await (const x of foo()) {
        console.log(x)
      }
    }
    bar()
    
    // New output (with --target=es6)
    function foo() {
      return __asyncGenerator(this, null, function* () {
        yield Promise.resolve(1);
        yield new __await(new Promise((r) => setTimeout(r, 100)));
        yield* __yieldStar([Promise.resolve(2)]);
      });
    }
    function bar() {
      return __async(this, null, function* () {
        try {
          for (var iter = __forAwait(foo()), more, temp, error; more = !(temp = yield iter.next()).done; more = false) {
            const x = temp.value;
            console.log(x);
          }
        } catch (temp) {
          error = [temp];
        } finally {
          try {
            more && (temp = iter.return) && (yield temp.call(iter));
          } finally {
            if (error)
              throw error[0];
          }
        }
      });
    }
    bar();
    

    This is an older feature that was added to JavaScript in ES2018 but I didn't implement the transformation then because it's a rarely-used feature. Note that esbuild already added support for transforming for await loops (the other part of the asynchronous iteration proposal) a year ago, so support for asynchronous iteration should now be complete.

    I have never used this feature myself and code that uses this feature is hard to come by, so this transformation has not yet been tested on real-world code. If you do write code that uses this feature, please let me know if esbuild's async generator transformation doesn't work with your code.

Readme

Source

esbuild

This is the cross-platform WebAssembly binary for esbuild, a JavaScript bundler and minifier. See https://github.com/evanw/esbuild and the JavaScript API documentation for details.

FAQs

Last updated on 25 Jun 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc