UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

26 lines 643 B
//#region src/number/orThrow.d.ts /** * `orThrow(target)` * * Returns the numeric value of `target` if it's a finite number, otherwise throws an error. * * ```ts * orThrow(42); // 42 * orThrow(NaN); // throws FnError * orThrow(Infinity); // throws FnError * orThrow("hello"); // throws FnError * ``` * * ```ts * pipe(42, orThrow()); // 42 * pipe(NaN, orThrow()); // throws FnError * pipe(Infinity, orThrow()); // throws FnError * pipe("hello", orThrow()); // throws FnError * ``` */ declare const orThrow: { (): <T>(target: T) => Extract<T, number>; <T>(target: T): Extract<T, number>; }; //#endregion export { orThrow };