filterArray
Import
Section titled “Import”import { filterArray } from 'ngxtension/filter-array';Apply a filtering function to an array emitted by an Observable.
import { of } from 'rxjs';import { filterArray } from 'ngxtension/filter-array';
const source$ = of([1, 2, 3]);const filtered$ = source$.pipe(filterArray((element) => element <= 2));Examples
Section titled “Examples”Example 1: Filter Even Numbers
Section titled “Example 1: Filter Even Numbers”const source$ = of([1, 2, 3, 4, 5]);const filtered$ = source$.pipe(filterArray((element) => element % 2 === 0));Inputs
Section titled “Inputs”filterFn: (item: T, index: number) => boolean- A function to filter the array, similar to JavaScript’s.filter()method.