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.

26 lines (24 loc) 785 B
import { both, complement, curryN } from 'ramda'; import isInteger from './isInteger.js'; import isNegative from './isNegative.js'; /** * Checks if value is a natural number. * Natural numbers correspond to all non-negative integers and 0. * * @func isNaturalNumber * @memberOf RA * @since {@link https://char0n.github.io/ramda-adjunct/2.29.0|v2.29.0} * @category Type * @sig * -> Boolean * @param {*} val The value to test * @return {boolean} * @example * * RA.isNaturalNumber(5); // => true * RA.isNaturalNumber(Number.MAX_VALUE); // => true * RA.isNaturalNumber(0); // => true * RA.isNaturalNumber(-1); // => false * RA.isNaturalNumber(0.9); // => false */ var isNaturalNumber = curryN(1, both(isInteger, complement(isNegative))); export default isNaturalNumber;