npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

numnum

v1.0.0

Published

Bunch of number operations and methods

Downloads

3

Readme

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']