float.flow
Library provides float
opquae type alias for number
and set of functions
to work with float
type values.
API
Import
Float.float:number
Library exposes float
, a subtype of a number
.
Float.parseFloat(string):?float
Try to turn given string into a float
, unlike built-in parseFloat
this function never return NaN
or an Infinity
, but rather retuns null
(?
portion of ?float
). It also unlike built-in parseFloat
fails (returns null
) on strings than aren't numbers like "0what?"
.
Float //> 123Float //> 3.14Float //> 3.14Float //> 3.14Float //> -3.14Float //> 0Float // > 0Float //> nullFloat //> nullFloat //> nullFloat //> nullFloat //> null
Float.toFloat(number):float
Turns any number into a float
. Useful for working with APIs that require float
type argument instead of number
.
Float //> 0Float // 1.5Float //> NaNFloat // Infinity
Float.isNaN(number):boolean
Returns true
if given number
is NaN
. Just an alias for JS built-in isNaN
.
Float //> trueFloat //> trueFloat //> falseFloat //> false
Float.isFinite(number):boolean
Return true
if given number
is finite (is neither NaN
nor (-
)Infinity
). It is just an alias for built-in isFinite
.
Float //> falseFloat //> falseFloat //> falseFloat //> falseFloat //> falseFloat //> trueFloat //> trueFloat //> true
Install
npm install float.flow