UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

27 lines (25 loc) 626 B
import { NonNil } from "../internals/types.js"; //#region src/option/or.d.ts /** * `or(target, or)` * * Returns the target value if it's not `null` or `undefined`, otherwise returns the fallback value. Uses the nullish coalescing operator to provide a default value for null or undefined inputs. * * ```ts * or(5, 10); // 5 * or(null, 10); // 10 * or(undefined, 10); // 10 * or(0, 10); // 0 * ``` * * ```ts * pipe(5, or(10)); // 5 * pipe(null, or(10)); // 10 * ``` */ declare const or: { <T, U>(or: U): (target: T) => NonNil<T> | U; <T, U>(target: T, or: U): NonNil<T> | U; }; //#endregion export { or };