UNPKG

ramda-adjunct

Version:

Ramda Adjunct is the most popular and most comprehensive set of utilities for use with Ramda, providing a variety of useful, well tested functions with excellent documentation.

29 lines (28 loc) 938 B
import { both, gte, flip } from 'ramda'; import curry1 from 'ramda/src/internal/_curry1'; import isNumber from './isNumber'; /** * Checks if value is a non-negative `Number` primitive or object. This includes all positive * numbers and zero. * * @func isNonNegative * @memberOf RA * @since {@link https://char0n.github.io/ramda-adjunct/2.6.0|v2.6.0} * @category Type * @sig * -> Boolean * @param {*} val The value to test * @return {boolean} * @see {@link RA.isPositive|isPositive}, {@link RA.isNonPositive|isNonPositive} * @example * * RA.isNonNegative(0); // => true * RA.isNonNegative(1); // => true * RA.isNonNegative(Infinity); // => true * RA.isNonNegative(Number.MAX_VALUE); // => true * * RA.isNonNegative(-Infinity); // => false * RA.isNonNegative(Number.MIN_VALUE); // => false * RA.isNonNegative(NaN); // => false */ var isNonNegative = curry1(both(isNumber, flip(gte)(0))); export default isNonNegative;