Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dec-int

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dec-int

Get a base-10 integer from a NumericString or Number.

  • 3.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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

FAQs

Package last updated on 03 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc