Skip to content

orThrow

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