Is there any known trick in JavaScript to tell the difference between Iterator and AsyncIterator, without triggering iteration?
I'm trying to implement the following type checker:
function isAsyncIterator<T>(i: Iterator<T> | AsyncIterator<T>): boolean {
// returns:
// - true, if i is an asycnronous iterator
// - false, if i is a syncronous iterator
}
I know that calling next would tell us so, but I need it at the point when I cannot trigger iteration.
Also, even though I gave the example in TypeScript, I need to check it strictly at run-time.