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

@putout/plugin-math

v4.0.0

Published

🐊Putout plugin helps with Math

Readme

@putout/plugin-math NPM version

🐊Putout plugin helps with Math.

Install

npm i @putout/plugin-math -D

Rules

{
    "rules": {
        "math/apply-exponentiation": "on",
        "math/apply-multiplication": "on",
        "math/apply-numeric-separators": "on",
        "math/convert-sqrt-to-hypot": "on",
        "math/declare": "on",
        "math/remove-unchanged-zero-declarations": "on"
    }
}

convert-sqrt-to-hypot

The Math.hypot() function returns the square root of the sum of squares of its arguments.

(c) MDN

Convert Math.sqrt() to Math.hypot(). Check out in 🐊Putout Editor.

❌ Example of incorrect code

Math.sqrt(a ** 2, b ** 2);

✅ Example of correct code

Math.hypot(a, b);

apply-exponentiation

  • The Math.pow() static method, given two arguments, base and exponent, returns baseexponent.
  • The exponentiation operator (**) returns the result of raising the first operand to the power of the second operand. It is equivalent to Math.pow, except it also accepts BigInts as operands.

(c) MDN

❌ Example of incorrect code

Math.pow(2, 4);

✅ Example of correct code

2 ** 4;

Comparison

Linter | Rule | Fix --------|-------|------------| 🐊 Putout | convert-math-pow | ✅ ⏣ ESLint | prefer-exponentiation-operator | ✅

apply-multiplication

Multiplying two numbers stored internally as integers (which is only possible with AsmJS with imul is the only potential circumstance where Math.imul() may prove performant in current browsers.

(c) MDN

Check out in 🐊Putout Editor.

❌ Example of incorrect code

const a = Math.imul(b, c);

✅ Example of correct code

const a = b * c;

apply-numeric-separators

To improve readability for numeric literals, underscores (_) can be used as separators.

(c) MDN

❌ Example of incorrect code

const t = 10000000;

✅ Example of correct code

const t = 10_000_000;

declare

The Math.round() static method returns the value of a number rounded to the nearest integer.

(c) MDN

❌ Example of incorrect code

round(bLength / aLength) > 3;

✅ Example of correct code

const {round} = Math;
round(bLength / aLength) > 3;

remove-unchanged-zero-declarations

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

for (let index = 0; index < n; index++) {
    const tokenDelta = 0;
    const templateDelta = 0;
    
    for (let templateIndex = 0; templateIndex < templateTokensLength; templateIndex++) {
        const currentTokenIndex = index + templateIndex - tokenDelta;
        const currentToken = tokens[currentTokenIndex];
        
        end = currentTokenIndex + tokenDelta;
    }
}

✅ Example of correct code

for (let index = 0; index < n; index++) {
    for (let templateIndex = 0; templateIndex < templateTokensLength; templateIndex++) {
        const currentTokenIndex = index + templateIndex;
        const currentToken = tokens[currentTokenIndex];
        
        end = currentTokenIndex;
    }
}

License

MIT