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

@hero-page/hero-math-functions

v1.0.0

Published

A set of mathematical functions for performing basic arithmetic operations, finding the min/max value in an array, and calculating mean, median, and mode

Downloads

9

Readme

This entire repository was created completely with AI, using the hero-ai-package-creator, which is open-source, uses GPT-4, and is written & maintained by Sam Chahine ❣️🧞‍♀️

hero-math-functions

A set of mathematical functions for performing basic arithmetic operations, finding the min/max value in an array, and calculating mean, median, and mode.

Functions

add

Adds two numbers together.

Test cases: add(2, 3) returns 5.

Extreme cases to handle: very large numbers, very small numbers.

Ignore non-numeric inputs.

subtract

Subtracts one number from another.

Test cases: subtract(7, 4) returns 3.

Extreme cases to handle: negative results and very large/small numbers.

Ignore non-numeric inputs.

multiply

Multiplies two numbers together.

Test cases: multiply(3, 5) returns 15.

Extreme cases to handle: very large/small numbers and products.

Ignore non-numeric inputs.

divide

Divides one number by another.

Test cases: divide(10, 2) returns 5.

Extreme cases to handle: dividing by zero and very large/small numbers.

Ignore non-numeric inputs.

min

Returns the minimum value in an array.

Test cases: min([1, 2, 3]) returns 1.

Extreme cases to handle: very large arrays and empty arrays.

Ignore non-numeric values.

max

Returns the maximum value in an array.

Test cases: max([1, 2, 3]) returns 3.

Extreme cases to handle: very large arrays and empty arrays.

Ignore non-numeric values.

mean

Calculates the mean (average) of an array of numbers.

Test cases: mean([1, 2, 3]) returns 2.

Extreme cases to handle: very large arrays, empty arrays, and arrays with non-numeric values.

Ignore non-numeric values.

median

Calculates the median (middle) value of an array of numbers.

Test cases: median([1, 2, 3]) returns 2.

Extreme cases to handle: very large arrays, empty arrays, and arrays with non-numeric values.

Ignore non-numeric values.

mode

Calculates the mode (most frequent) value in an array of numbers.

Test cases: mode([1, 2, 2, 3]) returns 2.

Extreme cases to handle: very large arrays, empty arrays, and arrays with non-numeric values.

Ignore non-numeric values.

abs

Returns the absolute value of a number.

Test cases: abs(-5) returns 5.

Extreme cases to handle: very large/small numbers.

Ignore non-numeric inputs.

square

Squares a number.

Test cases: square(4) returns 16.

Extreme cases to handle: very large/small numbers.

Ignore non-numeric inputs.

squareRoot

Returns the square root of a number.

Test cases: squareRoot(9) returns 3.

Extreme cases to handle: negative inputs and very large/small numbers.

Ignore non-numeric inputs.

power

Raises a number to the given exponent.

Test cases: power(2, 3) returns 8.

Extreme cases to handle: very large/small numbers and exponents.

Ignore non-numeric inputs.

round

Rounds a number to the nearest integer.

Test cases: round(3.5) returns 4.

Extreme cases to handle: very large/small numbers.

Ignore non-numeric inputs.

ceil

Rounds a number up to the nearest integer.

Test cases: ceil(3.2) returns 4.

Extreme cases to handle: very large/small numbers.

Ignore non-numeric inputs.

floor

Rounds a number down to the nearest integer.

Test cases: floor(3.7) returns 3.

Extreme cases to handle: very large/small numbers.

Ignore non-numeric inputs.

trunc

Truncates (removes the decimal) a number.

Test cases: trunc(3.7) returns 3.

Extreme cases to handle: very large/small numbers.

Ignore non-numeric inputs.

gcd

Finds the greatest common divisor (GCD) of two numbers.

Test cases: gcd(5, 10) returns 5.

Extreme cases to handle: very large/small numbers and negative inputs.

Ignore non-numeric inputs.

lcm

Finds the least common multiple (LCM) of two numbers.

Test cases: lcm(3, 5) returns 15.

Extreme cases to handle: very large/small numbers and negative inputs.

Ignore non-numeric inputs.

isPrime

Determines if a number is prime.

Test cases: isPrime(5) returns true.

Extreme cases to handle: very large/small numbers and non-integer inputs.

Ignore non-numeric inputs.

Sam Chahine, at Hero

Tests for abs

abs

Tests for floor

floor

Tests for gcd

gcd

Tests for ceil

ceil

Tests for lcm

lcm

Tests for max

max

Tests for mean

mean

Tests for median

median

Tests for isPrime

isPrime

Tests for mode

mode

Tests for multiply

multiply

Tests for power

power

Tests for round

round

Tests for min

min

Tests for squareRoot

squareRoot

Tests for subtract

subtract

Tests for trunc

trunc

Tests for square

square

Tests for add

add

Tests for divide

divide