JSFiddle - React, Tailwind, and code Playground
HTML
Look in the console.
JavaScript
async function* example() {
yield 1;
}
const a = (() => {
// From https://esdiscuss.org/topic/is-this-really-the-most-direct-way-to-get-asynciteratorprototype#content-0
const asyncGeneratorFunctionInstance = async function*(){};
const AsyncGeneratorFunction = Object.getPrototypeOf(asyncGeneratorFunctionInstance);
const AsyncGeneratorPrototype = AsyncGeneratorFunction.prototype;
const AsyncIteratorPrototype = Object.getPrototypeOf(AsyncGeneratorPrototype);
return AsyncIteratorPrototype;
})();
const b = (() => {
// From https://github.com/tc39/test262/blob/c55d2ab7c344e35a3ceb93cf1d4d30019584db82/harness/wellKnownIntrinsicObjects.js
const AsyncIteratorPrototype = ((async function * () {})())[Symbol.asyncIterator]();
return AsyncIteratorPrototype;
})();
const c = (() => {
// From https://github.com/ljharb/es-abstract/blob/master/GetIntrinsic.js#L40-L46
var hasSymbols = true;
var getProto = Object.getPrototypeOf;
var asyncGen = async function * () {};
//var asyncGenFunction = asyncGen ? getProto(asyncGen) : undefined;
var asyncGenIterator = asyncGen ? asyncGen() : undefined;
var AsyncIteratorPrototype = asyncGenIterator && hasSymbols && Symbol.asyncIterator ? asyncGenIterator[Symbol.asyncIterator]() : undefined;
return AsyncIteratorPrototype;
})();
console.log("a", a);
console.log("b", b);
console.log("c", c);
console.log("a === b", a === b);
console.log("a === c", a === c);
a.foo = "a";
b.foo = "b";
c.foo = "c";
(async () => {
try {
const it = example();
console.log("it.foo = ", it.foo); // "it.foo = a"
} catch (err) {
console.error(error);
}
})();