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

@utilify/math

v1.0.0

Published

The Utilify math functions are designed to simplify common and complex mathematical operations, with full type safety and optimized performance.

Downloads

77

Readme

Math Utilities

The math utility functions provide methods to perform common and complex mathematical operations. These functions can be extremely helpful for number manipulation, such as calculating averages, checking prime numbers, and other mathematical tasks.

Installation

To install the math utilities package, use one of the following commands, depending on your package manager:

npm install @utilify/math
yarn add @utilify/math
pnpm add @utilify/math

Once installed, you can import the functions into your project, using ESM or CJS.

import { average, clamp, divisors } from '@utilify/math';
const { average, clamp, divisors } = require('@utilify/math');

Overview

Here is an overview of the available functions in the math utilities package:

average

function average(values: number[]): number;

Returns the arithmetic average of the provided values.

clamp

function clamp(value: number, min: number, max: number): number;

Restricts the provided value to a range between a minimum and maximum value.

divisors

function divisors(num: number): number[];

Returns an array with all divisors of a number.

factorial

function factorial(value: number): number;

Calculates the factorial of a number.

fibonacci

function fibonacci(num: number): number;

Returns the Fibonacci number at the specified position.

frequency

function frequency<T>(arr: T[]): Record<string, number>;

Returns an object with the frequency of each value in an array.

isBetween

function isBetween(value: number, min: number, max: number): boolean;

Checks if a value is within a specific range.

isEven

function isEven(value: number): boolean;

Checks if the provided number is even.

isInteger

function isInteger(value: number): boolean;

Checks if the provided value is an integer.

isOdd

function isOdd(value: number): boolean;

Checks if the provided number is odd.

isPrime

function isPrime(num: number): boolean;

Checks if the provided number is prime.

random

function random(min: number = 0, max: number = 10): number;

Returns a random number between the provided minimum and maximum values.

round

function round(value: number, precision: number): number;

Rounds a number to the specified number of decimal places.

sum

function sum(values: number[]): number;

Returns the sum of all values in an array.

sumOfDigits

function sumOfDigits(num: number): number;

Returns the sum of the digits of a number.