@monstermann/fn
Version:
A utility library for TypeScript.
39 lines (37 loc) • 1.43 kB
TypeScript
import { ArrayGuard, ArrayMap, ArrayPredicate } from "./internals/types.js";
//#region src/array/findMapLast.d.ts
/**
* `findMapLast(array, predicate, mapper)`
*
* Finds the last element in `array` that satisfies the provided `predicate` function and applies the `mapper` function to it, returning a new array with the mapped element.
*
* ```ts
* findMapLast(
* [1, 2, 3, 4],
* (x) => x > 2,
* (x) => x * 10,
* ); // [1, 2, 3, 40]
* ```
*
* ```ts
* pipe(
* [1, 2, 3, 4],
* findMapLast(
* (x) => x > 2,
* (x) => x * 10,
* ),
* ); // [1, 2, 3, 40]
* ```
*/
declare const findMapLast: {
<T, U extends T>(predicate: ArrayGuard<T, U>, mapper: ArrayMap<T>): (target: T[]) => T[];
<T, U extends T>(predicate: ArrayGuard<T, U>, mapper: ArrayMap<T>): (target: readonly T[]) => readonly T[];
<T>(predicate: ArrayPredicate<T>, mapper: ArrayMap<T>): (target: T[]) => T[];
<T>(predicate: ArrayPredicate<T>, mapper: ArrayMap<T>): (target: readonly T[]) => readonly T[];
<T, U extends T>(target: T[], predicate: ArrayGuard<T, U>, mapper: ArrayMap<T>): T[];
<T, U extends T>(target: readonly T[], predicate: ArrayGuard<T, U>, mapper: ArrayMap<T>): readonly T[];
<T>(target: T[], predicate: ArrayPredicate<T>, mapper: ArrayMap<T>): T[];
<T>(target: readonly T[], predicate: ArrayPredicate<T>, mapper: ArrayMap<T>): readonly T[];
};
//#endregion
export { findMapLast };