Expose AsyncFunction, GeneratorFunction and AsyncGeneratorFunction

Add following properties on Function global object:

  • Function.async - initial value %AsyncFunction%
  • Function.generator - initial value %GeneratorFunction%
  • Function.asyncGenerator - initial value set to %AsyncGeneratorFunction%

These are mildly useful for code generation purposes. These builtins already exist in specification, but it's quite hard to access them.

since they're constructors, they'd need to be capitalized (Function.Async, Function.Generator, etc).

However, unfortunately due to the precedent of SharedArrayBuffer not being ArrayBuffer.Shared, etc, I suspect that they'd need to be added as three new top-level globals, if they were added at all.

(It would be very helpful to avoid needing syntax to reach these globals; i'd love to see them explicitly available)

1 Like