@monstermann/fn
Version:
A utility library for TypeScript.
26 lines (24 loc) • 774 B
TypeScript
import { ArrayPredicate } from "./internals/types.js";
//#region src/array/findRemoveLastOrThrow.d.ts
/**
* `findRemoveLastOrThrow(array, predicate)`
*
* Finds the last element in `array` that satisfies the provided `predicate` function and removes it, returning a new array without the removed element, or throws an error if no element is found.
*
* ```ts
* findRemoveLastOrThrow([1, 2, 3, 4], (x) => x > 2); // [1, 2, 3]
* ```
*
* ```ts
* pipe(
* [1, 2, 3, 4],
* findRemoveLastOrThrow((x) => x > 2),
* ); // [1, 2, 3]
* ```
*/
declare const findRemoveLastOrThrow: {
<T>(predicate: ArrayPredicate<T>): (target: readonly T[]) => T[];
<T>(target: readonly T[], predicate: ArrayPredicate<T>): T[];
};
//#endregion
export { findRemoveLastOrThrow };