Converts an asynchronous AsyncIterator into asynchronous AsyncIterable, so it can be used as a pipeline source/input.
Note that an iterator type can only be determined by starting the iteration, which is what this method does. So if getting the first iterator value throws an error, it will occur outside the pipeline.
Passing it an already iterable object will just reuse it.
Converts an array-like object into a synchronous Iterable, so it can be used as a pipeline source/input.
Converts a Promise into a one-value AsyncIterable, so it can be used as a pipeline source/input.
import {pipe, toIterable, spread} from 'iter-ops';
const input = Promise.resolve([1, 2, 3, 4, 5]);
const i = pipe(
toIterable(input),
spread()
); // = AsyncIterableExt<number>
for await(const a of i) {
console.log(a); // 1, 2, 3, 4, 5
}
Converts a simple value into a one-value synchronous iterable, so it can be used as a pipeline source/input.
Converts a synchronous
Iteratorinto a synchronousIterable, so it can be used as a pipeline source/input.Note that an iterator type can only be determined by starting the iteration, which is what this method does. So if getting the first iterator value throws an error, it will occur outside the pipeline.
Passing it an already iterable object will just reuse it.