main
Last change
on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
605 bytes
|
Line | |
---|
1 | import { ifElse, always } from 'ramda';
|
---|
2 |
|
---|
3 | import isCoercible from './internal/isCoercible';
|
---|
4 |
|
---|
5 | /**
|
---|
6 | * Converts value to a number.
|
---|
7 | *
|
---|
8 | * @func toNumber
|
---|
9 | * @memberOf RA
|
---|
10 | * @since {@link https://char0n.github.io/ramda-adjunct/2.36.0|v2.36.0}
|
---|
11 | * @category Type
|
---|
12 | * @param {*} val The value to convert
|
---|
13 | * @return {Number}
|
---|
14 | * @example
|
---|
15 | *
|
---|
16 | * RA.toNumber(3.2); //=> 3.2
|
---|
17 | * RA.toNumber(Number.MIN_VALUE); //=> 5e-324
|
---|
18 | * RA.toNumber(Infinity); //=> Infinity
|
---|
19 | * RA.toNumber('3.2'); //=> 3.2
|
---|
20 | * RA.toNumber(Symbol('3.2')); //=> NaN
|
---|
21 | */
|
---|
22 | const toNumber = ifElse(isCoercible, Number, always(NaN));
|
---|
23 |
|
---|
24 | export default toNumber;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.