UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

28 lines (26 loc) 554 B
import { dfdlT } from "@monstermann/dfdl"; //#region src/number/or.ts /** * `or(target, or)` * * Returns the numeric value of `target` if it's a finite number, otherwise returns the fallback value `or`. * * ```ts * or(42, 0); // 42 * or(NaN, 0); // 0 * or(Infinity, 0); // 0 * or("hello", 0); // 0 * ``` * * ```ts * pipe(42, or(0)); // 42 * pipe(NaN, or(0)); // 0 * pipe(Infinity, or(0)); // 0 * pipe("hello", or(0)); // 0 * ``` */ const or = dfdlT((target, or$1) => { return Number.isFinite(target) ? target : or$1; }, 2); //#endregion export { or };