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

@js-slayer/utils

v1.0.2

Published

A lightweight JavaScript utility library with helper functions for arrays, strings, numbers, dates, objects, and general utilities.

Readme

@js-slayer/utils ⚔️

A lightweight JavaScript utility library with helper functions for arrays, strings, numbers, dates, objects, and general utilities.


Installation

npm install @js-slayer/utils

Usage

import { 
  uniqueArray, chunkArray, shuffleArray, flattenArray, differenceArray, intersectionArray,
  capitalize, reverseString, truncateString, isPalindrome, randomString, countOccurrences, removeWhitespace,
  randomNumber, clamp, factorial, isPrime, gcd, lcm,
  formatDate, daysBetween, isLeapYear, addDays, subtractDays,
  deepClone, mergeObjects, isEmptyObject, getObjectKeys, getObjectValues, invertObject,
  debounce, throttle, sleep, generateUUID, isEmail 
} from "@js-slayer/utils";

API Reference

📦 Array Utilities

  • uniqueArray(arr) → Returns unique values from an array\
uniqueArray([1,1,2,3]); // [1,2,3]
  • chunkArray(arr, size) → Splits array into chunks\
chunkArray([1,2,3,4,5], 2); // [[1,2],[3,4],[5]]
  • shuffleArray(arr) → Randomly shuffles array\
shuffleArray([1,2,3,4]); // [3,1,4,2]
  • flattenArray(arr) → Flattens nested arrays\
flattenArray([1,[2,[3,4]],5]); // [1,2,3,4,5]
  • differenceArray(arr1, arr2) → Elements in arr1 but not arr2\
differenceArray([1,2,3], [2,3,4]); // [1]
  • intersectionArray(arr1, arr2) → Common elements between arrays\
intersectionArray([1,2,3], [2,3,4]); // [2,3]

🔤 String Utilities

  • capitalize(str) → Capitalizes first letter\
capitalize("hello"); // "Hello"
  • reverseString(str) → Reverses a string\
reverseString("abc"); // "cba"
  • truncateString(str, len) → Truncates string with ellipsis\
truncateString("Hello World", 5); // "Hello..."
  • isPalindrome(str) → Checks palindrome\
isPalindrome("madam"); // true
  • randomString(len) → Generates random string\
randomString(5); // "aZx9B"
  • countOccurrences(str, char) → Counts occurrences of a char\
countOccurrences("banana", "a"); // 3
  • removeWhitespace(str) → Removes all whitespaces\
removeWhitespace(" h e l l o "); // "hello"

🔢 Number Utilities

  • randomNumber(min, max) → Random number in range\
randomNumber(1, 10); // e.g. 7
  • clamp(num, min, max) → Clamps a number within range\
clamp(15, 0, 10); // 10
  • factorial(n) → Factorial of a number\
factorial(5); // 120
  • isPrime(n) → Checks prime\
isPrime(7); // true
  • gcd(a, b) → Greatest common divisor\
gcd(12, 18); // 6
  • lcm(a, b) → Least common multiple\
lcm(4, 6); // 12

📅 Date Utilities

  • formatDate(date) → Formats date as YYYY-MM-DD\
formatDate(new Date("2025-09-03")); // "2025-09-03"
  • daysBetween(date1, date2) → Difference in days\
daysBetween("2025-01-01", "2025-01-10"); // 9
  • isLeapYear(year) → Checks leap year\
isLeapYear(2024); // true
  • addDays(date, days) → Adds days to a date\
addDays(new Date("2025-01-01"), 5); // "2025-01-06"
  • subtractDays(date, days) → Subtracts days from a date\
subtractDays(new Date("2025-01-10"), 5); // "2025-01-05"

🧩 Object Utilities

  • deepClone(obj) → Deep clones object\
deepClone({a:1, b:{c:2}}); // {a:1, b:{c:2}}
  • mergeObjects(obj1, obj2) → Merges objects\
mergeObjects({a:1}, {b:2}); // {a:1,b:2}
  • isEmptyObject(obj) → Checks if object is empty\
isEmptyObject({}); // true
  • getObjectKeys(obj) → Gets object keys\
getObjectKeys({a:1,b:2}); // ["a","b"]
  • getObjectValues(obj) → Gets object values\
getObjectValues({a:1,b:2}); // [1,2]
  • invertObject(obj) → Swaps keys and values\
invertObject({a:1, b:2}); // {1:"a", 2:"b"}

⚡ General Utilities

  • debounce(fn, delay) → Debounces function\
const debounced = debounce(()=>console.log("Hi"), 500);
debounced();
  • throttle(fn, delay) → Throttles function\
const throttled = throttle(()=>console.log("Hi"), 500);
throttled();
  • sleep(ms) → Delays execution\
await sleep(1000); // waits 1s
  • generateUUID() → Generates UUID\
generateUUID(); // "3b12f1df-5232-4e3a-8bf2-3f6f4c8b9d3a"
  • isEmail(str) → Validates email format\
isEmail("[email protected]"); // true

License

MIT