1 | import { AsyncIterableX } from './asynciterablex';
|
2 | import { isIterable, isAsyncIterable, isArrayLike, isObservable, isPromise, } from '../util/isiterable';
|
3 | import { identityAsync } from '../util/identity';
|
4 | import { FromObservableAsyncIterable, FromPromiseIterable, FromAsyncIterable, FromArrayIterable, } from './from';
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | export function as(source) {
|
14 | if (source instanceof AsyncIterableX) {
|
15 | return source;
|
16 | }
|
17 | if (typeof source === 'string') {
|
18 | return new FromArrayIterable([source], identityAsync);
|
19 | }
|
20 | if (isIterable(source) || isAsyncIterable(source)) {
|
21 | return new FromAsyncIterable(source, identityAsync);
|
22 | }
|
23 | if (isPromise(source)) {
|
24 | return new FromPromiseIterable(source, identityAsync);
|
25 | }
|
26 | if (isObservable(source)) {
|
27 | return new FromObservableAsyncIterable(source, identityAsync);
|
28 | }
|
29 | if (isArrayLike(source)) {
|
30 | return new FromArrayIterable(source, identityAsync);
|
31 | }
|
32 | return new FromArrayIterable([source], identityAsync);
|
33 | }
|
34 |
|
35 |
|