as-number
v1.0.0
Published
typeof number, or use a default
Downloads
213,651
Maintainers
Readme
as-number
Tiny function that returns the given number, or a default value if typeof !== 'number'
. If no default is given, returns 0.
var number = require('as-number')
var num = number(arg0, 25) //default to 25
var num2 = number(arg1) //default to zero
Usage
number(value[, default])
If value
is typeof === 'number'
, then it simply returns value
unchanged. Otherwise, it will return default
if it is also a number, or zero.
License
MIT, see LICENSE.md for details.