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

light-math

v1.0.2

Published

A lightweight JavaScript utility for complex mathematical calculations and geometric formulas.

Readme

light-math 📐

A lightweight, fast, and versatile mathematical utility library for JavaScript and Node.js. Whether you're working on a React frontend or a Node.js backend, light-math provides essential tools for geometry, statistics, and number theory with zero dependencies.

🚀 Key Features

  • Hybrid Support: Works with ES Modules (ESM) and CommonJS (CJS).
  • Symbolic Math: Unique feature to return square roots in symbolic form (e.g., 2√2).
  • Comprehensive: 15+ functions covering Geometry, Statistics, and Number Theory.
  • Developer Friendly: Full JSDoc support for great Autocomplete in VS Code.

📦 Installation

npm install light-math

🔨 Usage

import {isPrime,getFactorial,getHypotenuse} from 'light-math';

console.log(isPrime(5)); //return true because 5 is prime number
console.log(isPrime(9)); // return false because 9 is not prime number  

console.log(getFactorial(5)); // return 120 

console.log(getHypotenuse(3,4)); // return 5 
console.log(getHypotenuse(6,2)); // return 6.3245.....
console.log(getHypotenuse(6,2,{isSymbolic:true})); //return 2√10

//see API Reference for other API docs

📚 API Reference

🔢 Number Theory & Arithmetic

| API | Description | Params | | ------------ | ---------------------------------------------------------------------------- | ------------------------------- | | getFactorial | Calculates the factorial of a number (n!). | n: number | | isPrime | Checks if a number is prime (true/false). | n: number | | getGCD | Calculates greatest common divisor (GCD). | a: number, b: number | | getLCM | Calculates least common multiple (LCM). | a: number, b: number | | isEven | Checks if a number is even. | num: number | | isOdd | Checks if a number is odd. | num: number |

🧮 Algebra

| API | Description | Params | |-----|-------------|--------| | findQuadraticEquationRoots | Find real roots of ax² + bx + c = 0 | a: number, b: number, c: number | | findVariableValueFromEquation | Solve linear equation with a variable string (e.g. "2x+3=7") | equation: string, variable: string |

📐 Geometry & Trigonometry

| API | Description | Params | | ------------- | ----------------------------------------------------------------- | ------------------------------------------------------- | | getHypotenuse | Calculates the hypotenuse of a triangle. Supports symbolic results (roots). | a: number, b: number, options?: {isSymbolic: boolean} | | getArea | Calculating the area of ​​flat shapes such as circle, triangle, square, and rectangle. | shape: string, ...args: number[] | | getVolume | Calculating the volume of sphere, pyramid, cube, prism geometric shapes. | shape: string, ...args: number[] | | getSlope | Calculating the slope of a line (gradient). | x1, y1, x2, y2: number | | getMidpoint | Find the midpoint between two coordinates. | x1, y1, x2, y2: number | | toRadians | Convert degrees to radians. | degrees: number |

📊Statistics

| API | Description | Params | |-----|-----------|--------| | getMean | get mean from number of arrays | numbers:number[] | | getMedian | get median from number of arrays | numbers:number[] | | getMode | get mode from number of arrays | numbers:[] | | getQuartiles | get quartiles from number of arrays | numbers:[] |

🤝Contribute

Want to conribute? lets fork the repository! Github Repo, you can add new API, fixing bugs or false logic

Lisensi: MIT License
(c) FadhilJmimy