Skip to content

Commit e59a970

Browse files
committed
refactor(async-iterable): allow synchronous iterables as input to async-iterable functions
1 parent 6fa2e5e commit e59a970

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

collections/async-iterable.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export type AsyncIterableLike<T> = Iterable<Promise<T>> | AsyncIterable<T>;
1+
export type AsyncIterableLike<T> = Iterable<Promise<T> | T> | AsyncIterable<T>;
22

33
export function filter<T, U extends T>(
44
iterable: AsyncIterableLike<T>,
@@ -108,7 +108,7 @@ export const asyncMapFn = mapFn;
108108

109109
export async function* asyncConcatMap<T, U>(
110110
iterable: AsyncIterableLike<T>,
111-
f: (element: T) => AsyncIterableLike<U> | Iterable<U>
111+
f: (element: T) => AsyncIterableLike<U>
112112
): AsyncIterable<U> {
113113
for await (const a of iterable) {
114114
for await (const b of f(a)) {
@@ -118,7 +118,7 @@ export async function* asyncConcatMap<T, U>(
118118
}
119119

120120
export function asyncConcatMapFn<T, U>(
121-
f: (element: T) => AsyncIterableLike<U> | Iterable<U>
121+
f: (element: T) => AsyncIterableLike<U>
122122
): (iterable: AsyncIterableLike<T>) => AsyncIterable<U> {
123123
return iterable => asyncConcatMap(iterable, f);
124124
}

0 commit comments

Comments
 (0)