@rxjs-ninja/rxjs-array
Version:
Operators for RxJS for filtering with boolean logic
36 lines (35 loc) • 1.26 kB
TypeScript
/**
* @packageDocumentation
* @module Array
*/
import { OperatorFunction, Subscribable } from 'rxjs';
/**
* Returns an Observable Array containing filtered values that are in both the source in the provided input Array or Set
*
* @category Filter
*
* @see [[intersects]] operator for an Array of unique intersection items
*
* @typeParam T Item type contained in the Array or Set
*
* @param input Array or Set or Observable value to compare against for the intersection
*
* @example
* Returns the intersection between the source array and the passed static array
* ```ts
* const input = ['a', 'b', 'd', 'a', 'b'];
* of(input).pipe(filterIntersects(['a', 'd'])).subscribe();
* ```
* Output: `'a', 'd', 'a'`
*
* @example
* Returns the intersection between the source array and the passed Observable array
* ```ts
* const input = ['a', 'b', 'd', 'a', 'b'];
* of(input).pipe(filterIntersects(of(['a', 'd']))).subscribe();
* ```
* Output: `'a', 'd', 'a'`
*
* @returns An Observable that emits an Array of the intersection of input and source arrays.
*/
export declare function filterIntersects<T extends unknown>(input: Subscribable<Iterable<T>> | Iterable<T>): OperatorFunction<Iterable<T>, T[]>;