New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@utilify/math

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@utilify/math

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

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
0
Created
Source

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.

Keywords

math

FAQs

Package last updated on 12 Jan 2025

Did you know?

Socket

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.

Install

Related posts