
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
@utilify/math
Advanced tools
The Utilify math functions are designed to simplify common and complex mathematical operations, with full type safety and optimized performance.
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.
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');
Here is an overview of the available functions in the math utilities package:
function average(values: number[]): number;
Returns the arithmetic average of the provided values.
function clamp(value: number, min: number, max: number): number;
Restricts the provided value to a range between a minimum and maximum value.
function divisors(num: number): number[];
Returns an array with all divisors of a number.
function factorial(value: number): number;
Calculates the factorial of a number.
function fibonacci(num: number): number;
Returns the Fibonacci number at the specified position.
function frequency<T>(arr: T[]): Record<string, number>;
Returns an object with the frequency of each value in an array.
function isBetween(value: number, min: number, max: number): boolean;
Checks if a value is within a specific range.
function isEven(value: number): boolean;
Checks if the provided number is even.
function isInteger(value: number): boolean;
Checks if the provided value is an integer.
function isOdd(value: number): boolean;
Checks if the provided number is odd.
function isPrime(num: number): boolean;
Checks if the provided number is prime.
function random(min: number = 0, max: number = 10): number;
Returns a random number between the provided minimum and maximum values.
function round(value: number, precision: number): number;
Rounds a number to the specified number of decimal places.
function sum(values: number[]): number;
Returns the sum of all values in an array.
function sumOfDigits(num: number): number;
Returns the sum of the digits of a number.
FAQs
The Utilify math functions are designed to simplify common and complex mathematical operations, with full type safety and optimized performance.
We found that @utilify/math demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.