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

number-helper-functions

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

number-helper-functions

Helper with multiple number-related methods

  • 2.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
132
decreased by-52%
Maintainers
1
Weekly downloads
 
Created
Source

NumberHelper

Kind: global class

  • NumberHelper
    • new NumberHelper()
    • .isNumber(n)boolean
    • .isInt(n)boolean
    • .isFloat(n)boolean
    • .isEven(n)boolean
    • .isOdd(n)boolean
    • .isFinite(n)boolean
    • .isPrime(num)boolean
    • .getRandom(min, max)number
    • .prefixWithZeros(number, length)string
    • .convertToNumber(toCheck, [decimals])number
    • .processNumber(value, [decimals])number

new NumberHelper()

NumberHelper Class

NumberHelper.isNumber(n) ⇒ boolean

Checks if element is a number

Kind: static method of NumberHelper
Returns: boolean - Whether the element is a number or not

ParamTypeDescription
nstring | numberThe element to check

NumberHelper.isInt(n) ⇒ boolean

Checks if element is an integer

Kind: static method of NumberHelper
Returns: boolean - Whether the number is an integer or not

ParamTypeDescription
nstring | numberNumber to check

NumberHelper.isFloat(n) ⇒ boolean

Checks if element is a float number

Kind: static method of NumberHelper
Returns: boolean - Whether the number is a float or not

ParamTypeDescription
nstring | numberNumber to check

NumberHelper.isEven(n) ⇒ boolean

Checks if number is even

Kind: static method of NumberHelper
Returns: boolean - Whether the number is even or not

ParamTypeDescription
nnumberNumber to check

NumberHelper.isOdd(n) ⇒ boolean

Checks if number is odd

Kind: static method of NumberHelper
Returns: boolean - Whether the number is odd or not

ParamTypeDescription
nnumberNumber to check

NumberHelper.isFinite(n) ⇒ boolean

Checks if numer is finite

Kind: static method of NumberHelper
Returns: boolean - Whether the number is finite or not

ParamTypeDescription
nnumberNumber to check

NumberHelper.isPrime(num) ⇒ boolean

Checks if number is prime

Kind: static method of NumberHelper
Returns: boolean - Whether the numbere is prime or not

ParamTypeDescription
numnumberNumber to check

NumberHelper.getRandom(min, max) ⇒ number

Gets random integer number in a range

Kind: static method of NumberHelper
Returns: number - Random number in range

ParamTypeDescription
minnumberMinimum number
maxnumberMaximum number

NumberHelper.prefixWithZeros(number, length) ⇒ string

Prefixes a number with zeros until desired length

Kind: static method of NumberHelper
Returns: string - Padded number as a string

ParamTypeDescription
numbernumberNumber to pad
lengthnumberDesired number length

NumberHelper.convertToNumber(toCheck, [decimals]) ⇒ number

Converts string to number

Kind: static method of NumberHelper
Returns: number - Converted number

ParamTypeDefaultDescription
toCheckstring | numberNumber-like to convert
[decimals]number2Number of decimals to truncate

NumberHelper.processNumber(value, [decimals]) ⇒ number

Processes number to get clean value

Kind: static method of NumberHelper
Returns: number - Parsed and processed number

ParamTypeDefaultDescription
valuestring | numberString or number to process
[decimals]number2No. of decimals to truncate to

FAQs

Package last updated on 04 May 2020

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