Socket
Socket
Sign inDemoInstall

strnum

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

strnum

Parse String to Number based on configuration


Version published
Weekly downloads
15M
increased by2.06%
Maintainers
1
Weekly downloads
 
Created

What is strnum?

The strnum npm package is used to convert strings to numbers in JavaScript. It provides a simple and efficient way to handle string-to-number conversions, including handling edge cases and different number formats.

What are strnum's main functionalities?

Basic String to Number Conversion

This feature allows you to convert a basic numeric string to a number. The example converts the string '123' to the number 123.

const strnum = require('strnum');

const num = strnum('123');
console.log(num); // 123

Handling Decimal Numbers

This feature allows you to convert a string representing a decimal number to a number. The example converts the string '123.45' to the number 123.45.

const strnum = require('strnum');

const num = strnum('123.45');
console.log(num); // 123.45

Handling Exponential Notation

This feature allows you to convert a string in exponential notation to a number. The example converts the string '1.23e4' to the number 12300.

const strnum = require('strnum');

const num = strnum('1.23e4');
console.log(num); // 12300

Handling Non-Numeric Strings

This feature returns the original string if it cannot be converted to a number. The example shows that the string 'abc' remains 'abc' after the conversion attempt.

const strnum = require('strnum');

const num = strnum('abc');
console.log(num); // 'abc'

Other packages similar to strnum

Keywords

FAQs

Package last updated on 10 Sep 2021

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