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

@jlhv/numeric-helper

v1.0.3

Published

A simple utility library for numeric manipulation.

Readme

Numeric Helper Library

Overview

The Numeric Helper Library provides a collection of utility functions for numeric operations, including mathematical calculations, validations, and conversions.

Installation

Install the package using:

npm install @jlhv/numeric-helper

Usage

Import the required functions from the library:

import { isEven, isOdd, factorial, gcd, lcm } from "@jlhv/numeric-helper";

console.log(isEven(4)); // Output: true
console.log(isOdd(3)); // Output: true
console.log(factorial(5)); // Output: 120
console.log(gcd(12, 18)); // Output: 6
console.log(lcm(12, 18)); // Output: 36

Functions

Basic Number Operations

    isEven(num: number): boolean

Checks if a number is even.

console.log(isEven(10)); // Output: true
console.log(isEven(7));  // Output: false
isOdd(num: number): boolean
  • Checks if a number is odd.
console.log(isOdd(10)); // Output: false
console.log(isOdd(7));  // Output: true
factorial(num: number): 
  • Returns the factorial of a number.
console.log(factorial(5)); // Output: 120
sum(arr: number[]): number
  • Returns the sum of an array of numbers.
console.log(sum([1, 2, 3, 4, 5])); // Output: 15
average(arr: number[]): number
  • Returns the average of an array of numbers.
console.log(average([2, 4, 6, 8, 10])); // Output: 6

Prime & Divisibility

isPrime(num: number): boolean
  • Checks if a number is prime.
console.log(isPrime(11)); // Output: true
console.log(isPrime(10)); // Output: false
gcd(a: number, b: number): number
  • Finds the greatest common divisor (GCD) of two numbers.
console.log(gcd(28, 35)); // Output: 7
lcm(a: number, b: number): number
  • Finds the least common multiple (LCM) of two numbers.
console.log(lcm(12, 15)); // Output: 60

Conversions

toBinary(num: number): string
  • Converts a number to binary.
console.log(toBinary(10)); // Output: "1010"
toHex(num: number): string
  • Converts a number to hexadecimal.
console.log(toHex(255)); // Output: "ff"
degToRad(degrees: number): number
  • Converts degrees to radians.
console.log(degToRad(180)); // Output: 3.14159
radToDeg(radians: number): number
  • Converts radians to degrees.
console.log(radToDeg(3.14159)); // Output: 180

Rounding & Clamping

clamp(num: number, min: number, max: number): number
  • Clamps a number within a given range.
console.log(clamp(15, 10, 20)); // Output: 15
console.log(clamp(25, 10, 20)); // Output: 20

Miscellaneous

randomInt(min: number, max: number): number
  • Generates a random integer between min and max.
console.log(randomInt(1, 100)); // Output: Random number between 1 and 100
power(base: number, exp: number): number
  • Computes the power of a number without using Math.pow().
console.log(power(2, 3)); // Output: 8
sqrt(num: number): number
  • Computes the square root of a number using the Babylonian method.
console.log(sqrt(25)); // Output: 5
nthRoot(num: number, n: number): number
  • Computes the nth root of a number using Newton’s method.
console.log(nthRoot(27, 3)); // Output: 3
isPerfectSquare(num: number): boolean
  • Checks if a number is a perfect square.
console.log(isPerfectSquare(36)); // Output: true
console.log(isPerfectSquare(37)); // Output: false 

License

ISC License.

Author

Vijayavel R.