UNPKG

@reactivex/ix-esnext-esm

Version:

The Interactive Extensions for JavaScript

1 lines 2.06 kB
{"version":3,"sources":["iterable/operators/filter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGvD,MAAM,OAAO,cAAwB,SAAQ,SAAkB;IAI7D,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,CAAC,GAAG,CAAC,CAAC;QACV,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE;YAC/B,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE;gBAC9B,MAAM,IAAI,CAAC;aACZ;SACF;IACH,CAAC;CACF;AAUD,MAAM,UAAU,MAAM,CACpB,SAAqD,EACrD,OAAa;IAEb,OAAO,SAAS,sBAAsB,CAAC,MAAyB;QAC9D,OAAO,IAAI,cAAc,CAAU,MAAM,EAAE,YAAY,CAAC,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;IAClF,CAAC,CAAC;AACJ,CAAC","file":"filter.js","sourcesContent":["import { IterableX } from '../iterablex';\nimport { bindCallback } from '../../util/bindcallback';\nimport { OperatorFunction } from '../../interfaces';\n\nexport class FilterIterable<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 i = 0;\n for (const item of this._source) {\n if (this._predicate(item, i++)) {\n yield item;\n }\n }\n }\n}\n\nexport function filter<T, S extends T>(\n predicate: (value: T, index: number) => value is S,\n thisArg?: any\n): OperatorFunction<T, S>;\nexport function filter<T>(\n predicate: (value: T, index: number) => boolean,\n thisArg?: any\n): OperatorFunction<T, T>;\nexport function filter<TSource>(\n predicate: (value: TSource, index: number) => boolean,\n thisArg?: any\n): OperatorFunction<TSource, TSource> {\n return function filterOperatorFunction(source: Iterable<TSource>): IterableX<TSource> {\n return new FilterIterable<TSource>(source, bindCallback(predicate, thisArg, 2));\n };\n}\n"]}