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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@t0ri/math

v5.2.1

Published

![npm](https://img.shields.io/npm/v/@t0ri/math) ![Travis (.com)](https://img.shields.io/travis/com/t0ri/FEW2.1-math) ![Coveralls github](https://img.shields.io/coveralls/github/t0ri/FEW2.1-math) ![GitHub repo size](https://img.shields.io/github/repo-size/

Downloads

51

Readme

npm Travis (.com) Coveralls github GitHub repo size

Math Library 🧮

A math library containing properties and methods extended onto Number.prototype.

Golden Ratio

Number.goldenRatio is equal to 1.61803398875.

let num = Number.goldenRatio
num -> 1.61803398875

Round

The .round() method rounds the Number it is called on to the nearest whole number.

let num = 9.99
num.round() -> 10

Ceil

The .ceil() method rounds the Number it is called on to the higher whole number.

let num = 9.99
num.ceil() -> 10

Floor

The .floor() method rounds the Number it is called on to the lower whole number.

let num = 9.99
num.floor() -> 9

Pad

The .pad(x, y) method pads the Number it is called on with 0s in order to reach a total of digits (x, y) on each side of the decimal point. Returns a String.

let num = 9.99
34.801.pad(4,3) -> 0009.990

Degrees to Radians

The .degToRad() method returns a number's radian value. Accepts an optional argument to return a fixed amount of decimal numbers.

let num = 1
num.degToRad() -> 0.017453292519943295
num.degToRad(6) -> 0.017453

Radians to Degrees

The .radToDeg() method returns a number's degree value. Accepts an optional argument to return a fixed amount of decimal numbers.

let num = 1
num.radToDeg() ->
num.radToDeg(4) -> 57.2958

Dollar Amount

The .toDollars() method returns a numeric value formatted in USD.

let num = 1
num.toDollars() -> '$1.00'

Tax

The .tax(rate) method returns an amount with tax applied. Accepts optional argument (number) to calculate tax on amount. Without argument, tax rate defaults to .25.

let num = 1
num.tax(0.25) -> 1.25

Interest

The .interest(months, rate) method calculates interest over time.

let num = 1
num.interest(2, 16) -> 1.35

Mortgage

The .mortgage(years, rate) method returns the monthly mortgage payment of the number it is called on. Rate is interest rate, years is the amount of months to pay.

let num = 1
num.mortgage(10, .02) -> 1

Number to Hex

The .toHex() method returns a string containing the hexadecimal value of the number it is caled on. This method accepts an optional boolean argument to control the return of an octothorpe.

let num = 12
num.toHex() -> 'c'
num.toHex(true) -> '#c'