mapArray
Import
Section titled “Import”import { mapArray } from 'ngxtension/map-array';Apply a map function to an array emitted by an Observable.
import { of } from 'rxjs';import { mapArray } from 'ngxtension/map-array';
const source$ = of([1, 2, 3]);const transformed$ = source$.pipe(mapArray((e) => e + 1));Examples
Section titled “Examples”Example 1: Double Array Elements
Section titled “Example 1: Double Array Elements”const source$ = of([1, 2, 3]);const transformed$ = source$.pipe(mapArray((e) => e * 2));// Output: [2, 4, 6]Inputs
Section titled “Inputs”mapFn: (item: T, index: number) => R- A function to transform each element of the array, similar to JavaScript’s.map()method.