import { convertAsyncIterable } from "https://deno.land/x/fathym_common@v0.2.22-integration/src/common/iterables/convertAsyncIterable.ts";
Convert an async iterable to an async iterable of another type.
Examples
From direct import
From direct import
import { convertAsyncIterable } from '@fathym/common/iterables';
const asyncIterable = {
[Symbol.asyncIterator]() {
let i = 0;
return {
next() {
if (i < 3) {
return Promise.resolve(i);
}
return Promise.resolve(i);
};
}
}
};
const ai = await convertAsyncIterable(asyncIterable, async (i) => i * 2);
console.log(Array.from(ai)); // [0, 2, 4, 6]
From common import
From common import
import { convertAsyncIterable } from '@fathym/common';
const ai = await convertAsyncIterable(asyncIterable, async (i) => i * 2);
console.log(Array.from(ai)); // [0, 2, 4, 6]