Is this really the most direct way to get %AsyncIteratorPrototype%?

T.J. Crowder tj.crowder at
Tue Aug 14 15:57:45 UTC 2018

This is the way I've found so far, allocating as few temporary objects as
possible (one, can't get rid of that temp function):

const AsyncIteratorPrototype =
            async function*(){}

or, showing the steps more clearly:

const asyncGeneratorFunctionInstance = async function*(){};
const AsyncGeneratorFunction = Object.getPrototypeOf(asyncGen
const AsyncGeneratorPrototype = AsyncGeneratorFunction.prototype;
const AsyncIteratorPrototype = Object.getPrototypeOf(AsyncGen

(I could create an async generator by calling that temporary async
generator function, but then I just have to do another
`Object.getPrototypeOf`, so it doesn't really buy me anything.)

Is there something more direct? (Remember that `AsyncGeneratorFunction`
isn't globally exposed like `Function` is. None of the new subclasses of
Function constructors are exposed; according to [this thread][1], there
weren't enough strong use cases [that thread is for `GeneratorFunction`,
but we can extrapolate].)

-- T.J. Crowder

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list