Skip to content

mapArray

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));
const source$ = of([1, 2, 3]);
const transformed$ = source$.pipe(mapArray((e) => e * 2));
// Output: [2, 4, 6]
  • mapFn: (item: T, index: number) => R - A function to transform each element of the array, similar to JavaScript’s .map() method.