(...items: (undefined | Promise<undefined> | Some<T>)[])
| 137 | export type Some<T> = T | Promise<T> | AsyncIterable<T | undefined> | AsyncIterable<Promise<T> | Promise<undefined>> | Iterable<T> | Iterable<Promise<T>>; |
| 138 | |
| 139 | export async function* asyncOf<T>(...items: (undefined | Promise<undefined> | Some<T>)[]): AsyncIterable<NonNullable<T>> { |
| 140 | if (is.asyncIterable(items)) { |
| 141 | for await (const item of items) { |
| 142 | if (is.asyncIterable(item) || is.iterable(item)) { |
| 143 | yield* item as any; |
| 144 | continue; |
| 145 | } |
| 146 | yield item as any; |
| 147 | } |
| 148 | return; |
| 149 | } |
| 150 | |
| 151 | for (const item of items) { |
| 152 | // skip undefined |
| 153 | if (item) { |
| 154 | if (is.asyncIterable(item) || is.iterable(item)) { |
| 155 | yield* item as any; |
| 156 | continue; |
| 157 | } |
| 158 | yield item as any; |
| 159 | } |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | /** |
| 164 | * A substitute for Promise.race() |
no test coverage detected