UNPKG

3.55 kBSource Map (JSON)View Raw
1{"version":3,"sources":["asynciterable/as.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EACL,UAAU,EACV,eAAe,EACf,WAAW,EACX,YAAY,EACZ,SAAS,GACV,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EACL,2BAA2B,EAC3B,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,QAAQ,CAAC;AA4BhB;;;;;;GAMG;AACH,kBAAkB;AAClB,MAAM,UAAU,EAAE,CAAC,MAAW;IAC5B,IAAI,MAAM,YAAY,cAAc,EAAE;QACpC,OAAO,MAAM,CAAC;KACf;IACD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC9B,OAAO,IAAI,iBAAiB,CAAC,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC,CAAC;KACvD;IACD,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,eAAe,CAAC,MAAM,CAAC,EAAE;QACjD,OAAO,IAAI,iBAAiB,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;KACrD;IACD,IAAI,SAAS,CAAC,MAAM,CAAC,EAAE;QACrB,OAAO,IAAI,mBAAmB,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;KACvD;IACD,IAAI,YAAY,CAAC,MAAM,CAAC,EAAE;QACxB,OAAO,IAAI,2BAA2B,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;KAC/D;IACD,IAAI,WAAW,CAAC,MAAM,CAAC,EAAE;QACvB,OAAO,IAAI,iBAAiB,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;KACrD;IACD,OAAO,IAAI,iBAAiB,CAAC,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC,CAAC;AACxD,CAAC","file":"as.js","sourcesContent":["import { AsyncIterableInput, AsyncIterableX } from './asynciterablex';\nimport {\n isIterable,\n isAsyncIterable,\n isArrayLike,\n isObservable,\n isPromise,\n} from '../util/isiterable';\nimport { identityAsync } from '../util/identity';\nimport {\n FromObservableAsyncIterable,\n FromPromiseIterable,\n FromAsyncIterable,\n FromArrayIterable,\n} from './from';\n\n/**\n * Converts an existing string into an async-iterable of characters.\n *\n * @export\n * @param {string} source The string to convert to an async-iterable.\n * @returns {AsyncIterableX<string>} An async-iterable stream of characters from the source.\n */\nexport function as(source: string): AsyncIterableX<string>;\n/**\n * Converts the async iterable like input into an async-iterable.\n *\n * @export\n * @template T The type of elements in the async-iterable like sequence.\n * @param {AsyncIterableInput<T>} source The async-iterable like input to convert to an async-iterable.\n * @returns {AsyncIterableX<T>} An async-iterable stream from elements in the async-iterable like sequence.\n */\nexport function as<T>(source: AsyncIterableInput<T>): AsyncIterableX<T>;\n/**\n * Converts the single element into an async-iterable sequence.\n *\n * @export\n * @template T The type of the input to turn into an async-iterable sequence.\n * @param {T} source The single element to turn into an async-iterable sequence.\n * @returns {AsyncIterableX<T>} An async-iterable sequence which contains the single element.\n */\nexport function as<T>(source: T): AsyncIterableX<T>;\n/**\n * Converts the input into an async-iterable sequence.\n *\n * @export\n * @param {*} source The source to convert to an async-iterable sequence.\n * @returns {AsyncIterableX<*>} An async-iterable containing the input.\n */\n/** @nocollapse */\nexport function as(source: any): AsyncIterableX<any> {\n if (source instanceof AsyncIterableX) {\n return source;\n }\n if (typeof source === 'string') {\n return new FromArrayIterable([source], identityAsync);\n }\n if (isIterable(source) || isAsyncIterable(source)) {\n return new FromAsyncIterable(source, identityAsync);\n }\n if (isPromise(source)) {\n return new FromPromiseIterable(source, identityAsync);\n }\n if (isObservable(source)) {\n return new FromObservableAsyncIterable(source, identityAsync);\n }\n if (isArrayLike(source)) {\n return new FromArrayIterable(source, identityAsync);\n }\n return new FromArrayIterable([source], identityAsync);\n}\n"]}
\No newline at end of file