Socket
Socket
Sign inDemoInstall

to-number-x

Package Overview
Dependencies
5
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    to-number-x

Converts argument to a value of type Number.


Version published
Maintainers
1
Install size
927 kB
Created

Readme

Source

Travis status Dependency status devDependency status npm version

to-number-x

Converts argument to a value of type Number.

Version: 2.0.0
Author: Xotic750 Xotic750@gmail.com
License: MIT
Copyright: Xotic750

to-number-x.toNumber

reference to toNumber2018.

Kind: static property of to-number-x

to-number-x.toNumber2016*

This method converts argument to a value of type Number. (ES2016)

Kind: static property of to-number-x
Returns: * - The argument converted to a number.
Throws:

  • TypeError - If argument is a Symbol or not coercible.
ParamTypeDescription
argument*The argument to convert to a number.

Example

var toNumber = require('to-number-x').toNumber2016;

toNumber('1'); // 1
toNumber(null); // 0
toNumber(true); // 1
toNumber('0o10'); // 8
toNumber('0b10'); // 2
toNumber('0xF'); // 16

toNumber(' 1 '); // 1

toNumber(Symbol('')) // TypeError
toNumber(Object.create(null)) // TypeError

to-number-x.toNumber2018*

This method converts argument to a value of type Number. (ES2018)

Kind: static property of to-number-x
Returns: * - The argument converted to a number.
Throws:

  • TypeError - If argument is a Symbol or not coercible.
ParamTypeDescription
argument*The argument to convert to a number.

Example

var toNumber = require('to-number-x').toNumber2018;

toNumber('1'); // 1
toNumber(null); // 0
toNumber(true); // 1
toNumber('0o10'); // 8
toNumber('0b10'); // 2
toNumber('0xF'); // 16

toNumber(' 1 '); // 1

toNumber(Symbol('')) // TypeError
toNumber(Object.create(null)) // TypeError

Keywords

FAQs

Last updated on 18 Oct 2017

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc