1 | import { curryN } from 'ramda';
|
---|
2 |
|
---|
3 | import isFunction from './isFunction';
|
---|
4 | import ponyfill from './internal/ponyfills/Number.isNaN';
|
---|
5 |
|
---|
6 | export const isNaNPonyfill = curryN(1, ponyfill);
|
---|
7 |
|
---|
8 | /**
|
---|
9 | * Checks whether the passed value is `NaN` and its type is `Number`.
|
---|
10 | * It is a more robust version of the original, global isNaN().
|
---|
11 | *
|
---|
12 | *
|
---|
13 | * @func isNaN
|
---|
14 | * @memberOf RA
|
---|
15 | * @since {@link https://char0n.github.io/ramda-adjunct/0.6.0|v0.6.0}
|
---|
16 | * @category Type
|
---|
17 | * @sig * -> Boolean
|
---|
18 | * @param {*} val The value to test
|
---|
19 | * @return {boolean}
|
---|
20 | * @see {@link RA.isNotNaN|isNotNaN}
|
---|
21 | * @example
|
---|
22 | *
|
---|
23 | * RA.isNaN(NaN); // => true
|
---|
24 | * RA.isNaN(Number.NaN); // => true
|
---|
25 | * RA.isNaN(0 / 0); // => true
|
---|
26 | *
|
---|
27 | * // e.g. these would have been true with global isNaN().
|
---|
28 | * RA.isNaN('NaN'); // => false
|
---|
29 | * RA.isNaN(undefined); // => false
|
---|
30 | * RA.isNaN({}); // => false
|
---|
31 | * RA.isNaN('blabla'); // => false
|
---|
32 | *
|
---|
33 | * RA.isNaN(true); // => false
|
---|
34 | * RA.isNaN(null); // => false
|
---|
35 | * RA.isNaN(37); // => false
|
---|
36 | * RA.isNaN('37'); // => false
|
---|
37 | * RA.isNaN('37.37'); // => false
|
---|
38 | * RA.isNaN(''); // => false
|
---|
39 | * RA.isNaN(' '); // => false
|
---|
40 | */
|
---|
41 | const _isNaN = isFunction(Number.isNaN)
|
---|
42 | ? curryN(1, Number.isNaN)
|
---|
43 | : isNaNPonyfill;
|
---|
44 |
|
---|
45 | export default _isNaN;
|
---|