Access awaited callback as an iterable:
callback
const fn = () => Math.random();for await (const v of fromFunctionAwaited(fn)) { // Generate infinite random numbers} Copy
const fn = () => Math.random();for await (const v of fromFunctionAwaited(fn)) { // Generate infinite random numbers}
callback can be async, result is awaited. This requires the use of for await. Use fromFunction otherwise;
for await
Access awaited
callbackas an iterable:callbackcan be async, result is awaited. This requires the use offor await. Use fromFunction otherwise;