@monstermann/fn
Version:
A utility library for TypeScript.
22 lines • 658 B
TypeScript
//#region src/array/removeAtOr.d.ts
/**
* `removeAtOr(target, idx, or)`
*
* Removes the element at index `idx` from `target` array. Supports negative indices to count from the end. If the index is out of bounds, returns the fallback value `or`.
*
* ```ts
* removeAtOr([1, 2, 3], 1, []); // [1, 3]
* removeAtOr([1, 2, 3], 5, []); // []
* ```
*
* ```ts
* pipe([1, 2, 3], removeAtOr(1, [])); // [1, 3]
* pipe([1, 2, 3], removeAtOr(5, [])); // []
* ```
*/
declare const removeAtOr: {
<U>(idx: number, or: U): <T>(target: readonly T[]) => T[] | U;
<T, U>(target: readonly T[], idx: number, or: U): T[] | U;
};
//#endregion
export { removeAtOr };