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:
905 bytes
|
Line | |
---|
1 | import { both, gte, flip, curryN } from 'ramda';
|
---|
2 |
|
---|
3 | import isNumber from './isNumber';
|
---|
4 |
|
---|
5 | /**
|
---|
6 | * Checks if value is a non-negative `Number` primitive or object. This includes all positive
|
---|
7 | * numbers and zero.
|
---|
8 | *
|
---|
9 | * @func isNonNegative
|
---|
10 | * @memberOf RA
|
---|
11 | * @since {@link https://char0n.github.io/ramda-adjunct/2.6.0|v2.6.0}
|
---|
12 | * @category Type
|
---|
13 | * @sig * -> Boolean
|
---|
14 | * @param {*} val The value to test
|
---|
15 | * @return {boolean}
|
---|
16 | * @see {@link RA.isPositive|isPositive}, {@link RA.isNonPositive|isNonPositive}
|
---|
17 | * @example
|
---|
18 | *
|
---|
19 | * RA.isNonNegative(0); // => true
|
---|
20 | * RA.isNonNegative(1); // => true
|
---|
21 | * RA.isNonNegative(Infinity); // => true
|
---|
22 | * RA.isNonNegative(Number.MAX_VALUE); // => true
|
---|
23 | *
|
---|
24 | * RA.isNonNegative(-Infinity); // => false
|
---|
25 | * RA.isNonNegative(Number.MIN_VALUE); // => false
|
---|
26 | * RA.isNonNegative(NaN); // => false
|
---|
27 | */
|
---|
28 | const isNonNegative = curryN(1, both(isNumber, flip(gte)(0)));
|
---|
29 |
|
---|
30 | export default isNonNegative;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.