New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

modern-number-utils

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

modern-number-utils

A collection of modern utility functions for handling numbers in JavaScript and TypeScript .

  • 1.0.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

modern-number-utils

A collection of modern utility functions for handling numbers in JavaScript and TypeScript .

Installation

You can install modern-number-utils using npm:

 npm install modern-number-utils

Usage

convertToInt(data: any): number

Converts the input to an integer. Validates that the input is a valid number.

import { convertToInt } from 'modern-number-utils';

const result = convertToInt('42');
console.log(result); // 42

convertToTwoDecimalInt(data: any): number

Converts the input to a number with two decimal places. Validates that the input is a valid number.

import { convertToTwoDecimalInt } from 'modern-number-utils';

const result = convertToTwoDecimalInt('42.123');
console.log(result); // 42.12


randomNumberWithFixedLength(length: number): number

Generates a random number with the specified length (number of digits).

import { randomNumberWithFixedLength } from 'modern-number-utils';

const result = randomNumberWithFixedLength(5);
console.log(result); // Random number with 5 digits




Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Keywords

FAQs

Package last updated on 17 Jan 2024

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