@monstermann/fn
Version:
A utility library for TypeScript.
23 lines (21 loc) • 570 B
TypeScript
import { NonNil } from "../internals/types.js";
//#region src/array/atOr.d.ts
/**
* `atOr(array, offset, fallback)`
*
* Returns the value at the specified `offset`. Returns `fallback` if the `offset` was out of range, or the retrieved value was nullable.
*
* ```ts
* atOr([1, null], -1, 2); // 2
* ```
*
* ```ts
* pipe([1, null], atOr(-1, 2)); // 2
* ```
*/
declare const atOr: {
<U>(offset: number, or: U): <T>(target: readonly T[]) => NonNil<T> | U;
<T, U>(target: readonly T[], offset: number, or: U): NonNil<T> | U;
};
//#endregion
export { atOr };