UNPKG

@reactivex/ix-esnext-esm

Version:

The Interactive Extensions for JavaScript

1 lines 3.79 kB
{"version":3,"sources":["iterable/operators/skipwhile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,MAAM,OAAO,iBAA2B,SAAQ,SAAkB;IAIhE,YAAY,MAAyB,EAAE,SAAqD;QAC1F,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;QAChB,IAAI,QAAQ,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,OAAO,EAAE;YAClC,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE;gBAC/C,QAAQ,GAAG,IAAI,CAAC;aACjB;YACD,IAAI,QAAQ,EAAE;gBACZ,MAAM,OAAO,CAAC;aACf;SACF;IACH,CAAC;CACF;AA6BD;;;;;;;;;GASG;AACH,MAAM,UAAU,SAAS,CACvB,SAA+C;IAE/C,OAAO,SAAS,yBAAyB,CAAC,MAAmB;QAC3D,OAAO,IAAI,iBAAiB,CAAI,MAAM,EAAE,SAAS,CAAC,CAAC;IACrD,CAAC,CAAC;AACJ,CAAC","file":"skipwhile.js","sourcesContent":["import { IterableX } from '../iterablex';\nimport { OperatorFunction } from '../../interfaces';\n\nexport class SkipWhileIterable<TSource> extends IterableX<TSource> {\n private _source: Iterable<TSource>;\n private _predicate: (value: TSource, index: number) => boolean;\n\n constructor(source: Iterable<TSource>, predicate: (value: TSource, index: number) => boolean) {\n super();\n this._source = source;\n this._predicate = predicate;\n }\n\n *[Symbol.iterator]() {\n let yielding = false;\n let i = 0;\n for (const element of this._source) {\n if (!yielding && !this._predicate(element, i++)) {\n yielding = true;\n }\n if (yielding) {\n yield element;\n }\n }\n }\n}\n\n/**\n * Bypasses elements in an async-iterale sequence as long as a specified condition is true\n * and then returns the remaining elements.\n *\n * @export\n * @template T The type of the elements in the source sequence.\n * @template S The result of the predicate that is truthy/falsy.\n * @param {(value: T, index: number) => value is S} predicate A function to test each element for a condition.\n * @returns {OperatorFunction<T, S>} An iterable sequence that contains the elements from the input\n * sequence starting at the first element in the linear series that does not pass the test specified by predicate.\n */\nexport function skipWhile<T, S extends T>(\n predicate: (value: T, index: number) => value is S\n): OperatorFunction<T, S>;\n/**\n * Bypasses elements in an async-iterale sequence as long as a specified condition is true\n * and then returns the remaining elements.\n *\n * @export\n * @template T The type of the elements in the source sequence.\n * @param {((value: T, index: number) => boolean)} predicate A function to test each element for a condition.\n * @returns {OperatorFunction<T, T>} An iterable sequence that contains the elements from the input\n * sequence starting at the first element in the linear series that does not pass the test specified by predicate.\n */\nexport function skipWhile<T>(\n predicate: (value: T, index: number) => boolean\n): OperatorFunction<T, T>;\n/**\n * Bypasses elements in an async-iterale sequence as long as a specified condition is true\n * and then returns the remaining elements.\n *\n * @export\n * @template T The type of the elements in the source sequence.\n * @param {((value: T, index: number) => boolean)} predicate A function to test each element for a condition.\n * @returns {OperatorFunction<T, T>} An iterable sequence that contains the elements from the input\n * sequence starting at the first element in the linear series that does not pass the test specified by predicate.\n */\nexport function skipWhile<T>(\n predicate: (value: T, index: number) => boolean\n): OperatorFunction<T, T> {\n return function skipWhileOperatorFunction(source: Iterable<T>): IterableX<T> {\n return new SkipWhileIterable<T>(source, predicate);\n };\n}\n"]}