import { AsyncIterableInput , AsyncIterableX } from './asynciterablex' ; import { isIterable , isAsyncIterable , isArrayLike , isObservable , isPromise , } from '../util/isiterable' ; import { identityAsync } from '../util/identity' ; import { FromObservableAsyncIterable , FromPromiseIterable , FromAsyncIterable , FromArrayIterable , } from './from' ; param { string } source returns { AsyncIterableX < string > } export function as ( source ) ; template T param { AsyncIterableInput < T > } source returns { AsyncIterableX < T > } export function as < T > ( source ) ; template T param { T } source returns { AsyncIterableX < T > } export function as < T > ( source ) ; param { * } source returns { AsyncIterableX < * > } nocollapse export function as ( source ) { if ( source instanceof AsyncIterableX ) { return source ; } if ( typeof source === 'string' ) { return new FromArrayIterable ( [ source ] , identityAsync ) ; } if ( isIterable ( source ) || isAsyncIterable ( source ) ) { return new FromAsyncIterable ( source , identityAsync ) ; } if ( isPromise ( source ) ) { return new FromPromiseIterable ( source , identityAsync ) ; } if ( isObservable ( source ) ) { return new FromObservableAsyncIterable ( source , identityAsync ) ; } if ( isArrayLike ( source ) ) { return new FromArrayIterable ( source , identityAsync ) ; } return new FromArrayIterable ( [ source ] , identityAsync ) ; }