UNPKG

2.73 kBSource Map (JSON)View Raw
1{"version":3,"sources":["iterable/as.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAqC5C,kBAAkB;AAClB,MAAM,UAAU,EAAE,CAAC,MAAW;IAC5B,IAAI,MAAM,YAAY,SAAS,EAAE;QAC/B,OAAO,MAAM,CAAC;KACf;IACD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC9B,OAAO,IAAI,YAAY,CAAC,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAC;KAC7C;IACD,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE;QACtB,OAAO,IAAI,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;KAC3C;IACD,IAAI,WAAW,CAAC,MAAM,CAAC,EAAE;QACvB,OAAO,IAAI,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;KAC3C;IACD,OAAO,IAAI,YAAY,CAAC,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC9C,CAAC","file":"as.js","sourcesContent":["import { IterableX } from './iterablex';\nimport { FromIterable } from './from';\nimport { isIterable, isArrayLike } from '../util/isiterable';\nimport { identity } from '../util/identity';\n\n/**\n * Converts an existing string into an iterable of characters.\n *\n * @export\n * @param {string} source The string to convert to an iterable.\n * @returns {IterableX<string>} An terable stream of characters from the source.\n */\nexport function as(source: string): IterableX<string>;\n/**\n * Converts the iterable like input into an iterable.\n *\n * @export\n * @template T The tyep of elements in the source iterable.\n * @param {Iterable<T>} source The iterable to convert to an iterable.\n * @returns {IterableX<T>} An iterable stream of the source sequence.\n */\nexport function as<T>(source: Iterable<T>): IterableX<T>;\n/**\n * Converts an array-like object to an iterable.\n *\n * @export\n * @template T The type of elements in the source array-like sequence.\n * @param {ArrayLike<T>} source The array-like sequence to convert to an iterable.\n * @returns {IterableX<T>} The iterable containing the elements from the array-like sequence.\n */\nexport function as<T>(source: ArrayLike<T>): IterableX<T>;\n/**\n * Converts the object into a singleton in an iterable sequence.\n *\n * @export\n * @template T The type of element to turn into an iterable sequence.\n * @param {T} source The item to turn into an iterable sequence.\n * @returns {IterableX<T>} An iterable sequence from the source object.\n */\nexport function as<T>(source: T): IterableX<T>;\n/** @nocollapse */\nexport function as(source: any) {\n if (source instanceof IterableX) {\n return source;\n }\n if (typeof source === 'string') {\n return new FromIterable([source], identity);\n }\n if (isIterable(source)) {\n return new FromIterable(source, identity);\n }\n if (isArrayLike(source)) {\n return new FromIterable(source, identity);\n }\n return new FromIterable([source], identity);\n}\n"]}
\No newline at end of file