ramda-adjunct
ramda-adjunct copied to clipboard
toNumber
Is your feature request related to a problem? Please describe.
Converts value to a number. Under the hood we will use Javascripts native Number function and we have to explicitly handle exceptions like Symbols and noncoercible objects before we pass the value to Number
function.
Describe the solution you'd like
toNumber('1'); //=> 1
toNumber('abc'); //=> NaN
toNumber(Symbol.for('test')); //=> NaN
toNumber(Object.create(null)); //=> NaN
Describe alternatives you've considered
Javascripts native Number function
Additional context
ES5 abstract ToNumber operation. Read this to understand how different values in JavaScript coerce to numbers and ideally incorporate those information into tests for toNumber
.
Will try to implement this today