dec-int
TypeScript icon, indicating that this package has built-in type declarations

3.0.1 • Public • Published

dec-int

Returns a base-10 integer from a NumericString or Number. Returns NaN if input can't be coerced to an integer.

decInt('56') // => 56

What is a NumericString?

Anything that would be a number if it didn't have quotes around it. For example, these are all numeric strings:

'5' or "5"
'123.456' or "123.456"
'-0' or "-0"
'0xFFFFFF' or "0xFFFFFF"
'020' or "020"

However, these are examples of what's not a NumericString:

"Infinity"
"Math.PI"
"PI"
"e"

Note: any input that is equivalent to negative-zero (except negative-zero itself) will evaluate to positive-zero. For example:

decInt(0); // => 0
decInt(-0); // => -0
decInt('-0'); // => 0
decInt('-0.5'); // => 0

Readme

Keywords

none

Package Sidebar

Install

npm i dec-int

Weekly Downloads

1

Version

3.0.1

License

MIT

Unpacked Size

3.74 kB

Total Files

5

Last publish

Collaborators

  • brycehanscomb