import { SafeUint } from 'ts-data-forge'; import { type KeepInitialValueOperator } from '../types/index.mjs'; /** * Transforms each value emitted by the source using a mapping function that also receives the emission index. * * @template A - The type of values from the source * @template B - The type of mapped values * @param mapFn - A function that maps each value (receives value and index) * @returns An operator that maps values with index * * @example * ```ts * // Timeline: * // * // num$ "A" "B" "C" * // indexed$ "0: A" "1: B" "2: C" * // * // Explanation: * // - mapWithIndex transforms each value along with its index * // - Index starts at 0 and increments with each emission * * const num$ = source(); * * const indexed$ = num$.pipe(map((x, i) => `${i}: ${x}`)); * * const valueHistory: string[] = []; * * indexed$.subscribe((s) => { * valueHistory.push(s); * }); * * num$.next('A'); // 0: A * * num$.next('B'); // 1: B * * num$.next('C'); // 2: C * * assert.deepStrictEqual(valueHistory, ['0: A', '1: B', '2: C']); * ``` */ export declare const map: (mapFn: (x: A, index: SafeUint | -1) => B) => KeepInitialValueOperator; //# sourceMappingURL=map.d.mts.map