ramda-adjunct icon indicating copy to clipboard operation
ramda-adjunct copied to clipboard

toNumber

Open char0n opened this issue 6 years ago • 1 comments

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.

char0n avatar Dec 31 '18 12:12 char0n

Will try to implement this today

mellero avatar Oct 05 '20 17:10 mellero