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

numnum

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

numnum

Bunch of number operations and methods

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

numnum

Bunch of number operations and methods

NPM version Build js-standard-style

Installation

npm install numnum --save

Usage

Javascript

var numnum = require('numnum');

TypeScript

import { <name-of-the-function> } from 'numnum';

Functions

stringToNumber

Convert string to number

Javascript

numnum.stringToNumber(['1', -4, 'rr5', 1, '7', -8, 5.6, -10, .6]);  => [1, -4, 5, 1, 7, -8, 5.6, -10, 0.6] ;

numnum.stringToNumber(['3$a', '$4b', '5$$$c']) => [3, 4, 5];

numnum.stringToNumber('2r1ee0') => 210

Typescript

import { stringToNumber } from 'numnum';

stringToNumber(['1', -4, 'rr5', 1, '7', -8, 5.6, -10, .6]);  => [1, -4, 5, 1, 7, -8, 5.6, -10, 0.6] ;

stringToNumber(['3$a', '$4b', '5$$$c']) => [3, 4, 5];

stringToNumber('2r1ee0') => 210

sortNumbers

Sort numbers

Javascript

numnum.sortNumbers(['1',-4,'rr5',1,'7', -8, 5.6, -10 , .6]) => [-10,-8,-4,0.6,1,1,5,5.6,7]

numnum.sortNumbers(['1',-4,'rr5',1,'7',-8, 5.6,-10 ,.6], 'dscending') => [7,5.6,5,1,1,0.6,-4,-8,-10]
Typescript

import { sortNumbers } from 'numnum';

sortNumbers(['1',-4,'rr5',1,'7', -8, 5.6, -10 , .6]) => [-10,-8,-4,0.6,1,1,5,5.6,7]

sortNumbers(['1',-4,'rr5',1,'7',-8, 5.6,-10 ,.6], 'dscending') => [7,5.6,5,1,1,0.6,-4,-8,-10]

removeCharacters

Remove characters from numbers

Javascript

numnum.removeCharacters(['2$n','1ERe','asd3']) => [2,1,3]

numnum.removeCharacters(['3fa','ff4b','5fffc'], 'f') => ['3a','4b', '5c']

numnum.removeCharacters(['3a','a4','5aaa'], /a/g) => ['3','4', '5']

numnum.removeCharacters('maytheforce420withyou') => 420

numnum.removeCharacters('ddddd2ddd2ddd0', 'd') => 220

numnum.removeCharacters('maytheforce420withyou', /y/g) => 'matheforce420withou'
Typescript

import { removeCharacters } from 'numnum';

removeCharacters(['2$n','1ERe','asd3']) => [2,1,3]

removeCharacters(['3fa','ff4b','5fffc'], 'f') => ['3a','4b', '5c']

removeCharacters(['3a','a4','5aaa'], /a/g) => ['3','4', '5']

removeCharacters('maytheforce420withyou') => 420

removeCharacters('ddddd2ddd2ddd0', 'd') => 220

removeCharacters('maytheforce420withyou', /y/g) => 'matheforce420withou'

positiveToNegative

Convert number from positive to negative

Javascript

numnum.positiveToNegative([2,1,3]) => [-2,-1,-3]

numnum.positiveToNegative(312) => -312
Typescript

import { positiveToNegative } from 'numnum';

positiveToNegative([2,1,3]) => [-2,-1,-3]

positiveToNegative(312) => -312

negativeToPositive

Convert number from negative to positive

Javascript

numnum.negativeToPositive([-2,-1,-3]) => [2,1,3]

numnum.negativeToPositive(-312) => 312
Typescript

import { negativeToPositive } from 'numnum';

negativeToPositive([-2,-1,-3]) => [2,1,3]

negativeToPositive(-312) => 312

thousandSeparator

Convert number from negative to positive

Javascript

numnum.thousandSeparator([20000,100000,1000000]) => ['20,000','100,000','1,000,000']

numnum.thousandSeparator(2000) => '2,000'
Typescript

import { thousandSeparator } from 'numnum';

thousandSeparator([20000,100000,1000000]) => ['20,000','100,000','1,000,000']

thousandSeparator(2000) => '2,000'

addCharacter

Add characters to numbers

Javascript

numnum.addCharacter([20,100,10], '$') => ['$20','$100','$10']

numnum.addCharacter(2000, '%', 'end') => ''2000%'
Typescript

import { addCharacter } from 'numnum';

addCharacter([20,100,10], '$') => ['$20','$100','$10']

addCharacter(2000, '%', 'end') => ''2000%'

add

Add numbers

Javascript

numnum.add([20,100,10,'-30',10.5]) => 110.5

Typescript

import { add } from 'numnum';

add([20,100,10,'-30',10.5]) => 110.5

percentage

Javascript

numnum.percentage(1) => 100

 numnum.percentage(2, true) => '200%'

Typescript

import { percentage } from 'numnum';

percentage(1) => 100

percentage(2, true) => '200%'

addDecimal

Javascript

numnum.addDecimal([7000,10,1,3], 2) => ['7000.00', '10.00', '1.00', '3.00']

numnum.addDecimal(499, 3) => '499.000'

Typescript

import { addDecimal } from 'numnum';

addDecimal([7000,10,1,3], 2) => ['7000.00', '10.00', '1.00', '3.00']

addDecimal(499, 3) => '499.000'

removeDecimal

Javascript

numnum.removeDecimal([20.33,100.4,10.2,'-30',10.5]) => [20,100,10,-30,10]

numnum.removeDecimal(100.201) => 100

Typescript

import { removeDecimal } from 'numnum';

removeDecimal([20.33,100.4,10.2,'-30',10.5]) => [20,100,10,-30,10]

removeDecimal(100.201) => 100

Tip : addDecimal(thousandSeparator([20000,100000,1000000]),1) => ['20,000.0','100,000.0','1,000,000.0']

Keywords

FAQs

Package last updated on 26 Apr 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