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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cenz/math-lib

v1.0.0

Published

The utlimate extension of the Number object built into javascript

Readme

math-lib

Travis (.com) Codecov GitHub repo size David

Description

An extension of the Number prototype chain to add some more functions to the Number object. More information about what this extension adds can be found in the API section.

API

Table of Contents

round

Round a number to it's nearest whole number

Returns Number the closest whole number to the original number

floor

Round a number down to it's nearest whole number.

Returns Number the closest whole number to the rounded down original number.

ceil

Round a number up to it's closest whole number

Examples

Number(5.32).ceil() -> 6

Returns Number the closest whole number to the rounded up original number.

pad

Pad a number with a specified amount of zeros (On either the left or right side)

Parameters

  • leftPadding
  • rightPadding

Examples

Number(5.3234).pad(4,5) -> 0004.32340
Number(4.34).pad(2,0) -> 04.34
Number(23.32).pad(10,10) -> 0000000023.3200000000

Returns String A padded string that indicates.

degToRad

Convert a number from degrees to radians

Examples

Number(20).degToRad() -> 0.349066

Returns Number The converted number in radians

radToDeg

Convert a number from radians to degrees

Examples

Number(1).radToDeg() -> 57.2958

Returns Number the converted number in degrees.

toDollars

Convert a number to USD.

Examples

Number(1).toDollars() -> $1.00
 Number(1.05).toDollars() -> $1.05
 Number(0.5).toDollars() -> ¢0.5

Returns String The dollar representation of the number

tax

Return the tax amount from the number that would be applied given the rate

Parameters

  • rate Number The tax rate to be applied where the rate is 0 <= rate <= 100 or the rate is 0 <= 100

Examples

Number(10).tax(10) -> 1.00
 Number(60).tax(25) -> 15.00

Returns Number the total tax amount of the current number multiplied by the rate

withTax

Return this number with a specified tax rate applied to it.

Parameters

  • rate Number The tax rate to be applied

Examples

Number(10).withTax(10) -> 11
 Number(200).withTax(50) -> 300

Returns Number a new number that has the tax of the original number applied.

interest

Calculate the interest on a number given the interest rate, years, and optional decimal places to round to

Parameters

  • rate Number The interest rate
  • years Number The amount of years the rate is applied to return {String} a string containing the total interest paid on a given number
  • decimalPlaces (optional, default 2)

mortage

Calculate the monthly payments for a mortage given a principal (Number)

Parameters

  • interestRate Number The yearly rate of interest
  • numberOfYears Number the years remaining for the mortage

Returns Number The monthly mortage payments that need to be made to pay off the mortage

decimalToHex

convert a decimal number to hexadecimal, all thanks to the help of this stack overflow question: https://stackoverflow.com/questions/57803/how-to-convert-decimal-to-hexadecimal-in-javascript

Returns String The string containing the number converted to hexadecimal

GOLDENRATIO

The golden ratio as approximated by: https://en.wikipedia.org/wiki/Golden_ratio

Type: Number