source: node_modules/ramda-adjunct/src/isNaturalNumber.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 784 bytes
RevLine 
[d24f17c]1import { both, complement, curryN } from 'ramda';
2
3import isInteger from './isInteger';
4import isNegative from './isNegative';
5
6/**
7 * Checks if value is a natural number.
8 * Natural numbers correspond to all non-negative integers and 0.
9 *
10 * @func isNaturalNumber
11 * @memberOf RA
12 * @since {@link https://char0n.github.io/ramda-adjunct/2.29.0|v2.29.0}
13 * @category Type
14 * @sig * -> Boolean
15 * @param {*} val The value to test
16 * @return {boolean}
17 * @example
18 *
19 * RA.isNaturalNumber(5); // => true
20 * RA.isNaturalNumber(Number.MAX_VALUE); // => true
21 * RA.isNaturalNumber(0); // => true
22 * RA.isNaturalNumber(-1); // => false
23 * RA.isNaturalNumber(0.9); // => false
24 */
25
26const isNaturalNumber = curryN(1, both(isInteger, complement(isNegative)));
27
28export default isNaturalNumber;
Note: See TracBrowser for help on using the repository browser.