Number Methods
Path:
/src/mod/number.coffee
compiled to/lib/mod/number.js
isInteger()
This method will check that the given value is an integer.
Usage:
isInteger(value)
- Parameter
-
value
- the number to check
- Return
Boolean
true
ifvalue
is an integer
isNumber()
This method will check that the given value is a number.
Usage:
isNumber(value)
- Parameter
-
value
- the number to check
- Return
Boolean
true
ifvalue
is a number
parseInt()
Strict parsing of numbers. This will fail on all strings which are no real integer.
Usage:
parseInt(value)
- Parameter
-
value
- the number to check
- Return
Number
value as Number orNaN
- See also
-
- To check if you got a number or invalid string useisNaN().
parseSeconds()
Parse human readable time to seconds.
With this parser it is possible to read a time interval in human format
like: 1h 30m
.
Example:
CoffeeScript Code number.parseSeconds 200 # 200
number.parseSeconds '200s' # 200
number.parseSeconds '200S' # 200
number.parseSeconds '5m' # 300
number.parseSeconds '1h' # 3600
number.parseSeconds '2.5h' # 9000
number.parseSeconds '1d' # 86400
number.parseSeconds '2h 5m 100s' # 7600
Usage:
parseSeconds(value)
- Parameter
-
value
-String
the time to transform into seconds
- Return
Number
value as Number orNaN
- See also
- -
parseMSeconds()
To check if you got a number or invalid string use isNaN()
.
parseMSeconds()
Parse human readable time to milliseconds. It will work the same as above and
you may specify ms
as additional unit here.
Usage:
parseMSeconds(value)
- Parameter
-
value
-String
the time to transform into seconds
- Return
Number
value as Number orNaN
- See also
- -
parseSeconds()
To check if you got a number or invalid string use isNaN()
.