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

@peterbenoit/utility-helpers

v1.0.0

Published

A comprehensive collection of JavaScript utility functions for image processing, array manipulation, string operations, and more.

Downloads

34

Readme

UtilityHelpers

A comprehensive collection of JavaScript utility functions for image processing, array manipulation, string operations, object utilities, date helpers, validation, DOM utilities, and more.

Author: Peter Benoit License: MIT GitHub: peterbenoit/UtilityHelpers


CDN Usage

jsDelivr (recommended)

<!-- Pinned to a specific version -->
<script src="https://cdn.jsdelivr.net/npm/@peterbenoit/[email protected]/utilityHelpers.js"></script>

<!-- Always latest -->
<script src="https://cdn.jsdelivr.net/npm/@peterbenoit/utility-helpers/utilityHelpers.js"></script>

unpkg

<!-- Pinned to a specific version -->
<script src="https://unpkg.com/@peterbenoit/[email protected]/utilityHelpers.js"></script>

<!-- Always latest -->
<script src="https://unpkg.com/@peterbenoit/utility-helpers/utilityHelpers.js"></script>

After including the script, UtilityHelpers is available as a global class:

const uuid = UtilityHelpers.generateUUID();
const chunks = UtilityHelpers.chunk([1, 2, 3, 4], 2);
const hex = UtilityHelpers.rgbToHex(255, 0, 0);

npm / Node.js

npm install @peterbenoit/utility-helpers
const UtilityHelpers = require('@peterbenoit/utility-helpers');

const uuid = UtilityHelpers.generateUUID();

Documentation

Full API documentation with live examples is available at the project homepage.


Methods

Image Utilities

  • getImageDetails(imageSrc, calculateAverageColor?) — width, height, size, format, orientation
  • getImageOrientation(image)'landscape' | 'portrait' | 'square'
  • getImageFormat(mimeType) — human-readable format name from MIME type
  • getAverageImageColor(imageSrc) — average rgb color of an image
  • getImageBase64(imageSrc, options?) — base64-encoded data URL
  • getLuminance(color) — relative luminance value
  • getContrastRatio(color1, color2) — WCAG contrast ratio
  • formatBytes(bytes, decimals?) — human-readable file size

Array Utilities

  • chunk(array, size) — split into chunks
  • shuffleArray(array) — random shuffle (non-mutating)
  • flattenArray(arr) — deep flatten
  • sumArray(arr) — sum of values
  • countUniqueElements(arr) — count of distinct values
  • findDuplicates(arr) — array of duplicate values
  • countOccurrences(arr, val) — count of a specific value
  • getRandomElement(arr) — random element
  • getMedian(arr) — median value
  • range(start, end, step?) — numeric range array
  • groupBy(array, key) — group by key or function

String Utilities

  • capitalizeWords(str) — title case
  • pluralize(word, count) — smart pluralization
  • escapeHtml(str) / unescapeHtml(str) — HTML entity handling
  • randomString(length) — random alphanumeric string
  • numberToWords(num) — number to English words (supports negatives)
  • escapeRegex(str) — escape special regex characters
  • camelCase(str) / kebabCase(str) / snakeCase(str) — case conversion
  • truncate(str, length?) — truncate with ellipsis
  • stripHtml(str) — remove HTML tags

Object Utilities

  • pick(object, keys) — select keys
  • omit(object, keys) — exclude keys
  • isEqual(a, b) — deep equality check
  • deepMerge(target, source) — deep immutable merge
  • getType(value)'array' | 'object' | typeof
  • isObjectEmpty(obj) — empty object check

Date & Time

  • randomDateBetweenTwo(start, end) — random date in range
  • timeStampID() — unique timestamp-based ID

General Utilities

  • generateUUID() — UUID v4
  • rgbToHex(r, g, b) — RGB to hex
  • limitDecimalPlaces(num, places) — precision control
  • generateRandomColor() — random hex color
  • getQueryParams(url) — parse URL query string
  • getURLParts(url) — parse URL components
  • shortenURL(url) / expandURL(encoded) — base64-url encode/decode
  • levenshteinDistance(str1, str2) — edit distance
  • clamp(value, min, max) — clamp number
  • parseJSON(str, fallback?) — safe JSON parse
  • formatNumber(num, locale?) — locale-formatted number
  • formatCurrency(amount, currency?, locale?) — locale-formatted currency
  • getFileExtension(filename) — file extension

Performance & Optimization

  • debounce(fn, delay) — delay execution until quiet
  • throttle(fn, limit) — limit execution rate
  • memoize(fn) — cache results
  • wait(ms) / sleep(ms) — async delay
  • retry(fn, attempts?, delay?) — retry with exponential backoff
  • once(fn) — execute only once
  • pipe(...fns) / compose(...fns) — function composition

Validation & Sanitization

  • isValidEmail(email) — email format check
  • isValidURL(url) — URL format check
  • validateAndSanitizeInput(inputElement, type, options?) — form input validation

DOM & UI

  • copyToClipboard(text) — clipboard write
  • smoothScrollTo(selector) — smooth scroll
  • toggleClassAfterDelay(element, className, delay) — delayed class toggle
  • detectUserIdleTime(callback, idleTime?) — idle detection (returns cancel fn)
  • getFormData(formElement) — form data as object
  • downloadFile(content, filename, mimeType?) — trigger download
  • toggleFullscreen(element?) — fullscreen toggle
  • lazyLoadImages(selector?) — intersection observer lazy load
  • getCSSVariable(name, element?) / setCSSVariable(name, value, element?) — CSS custom properties
  • saveScrollPosition() / restoreScrollPosition() — scroll position persistence
  • textToSpeech(text, options?) / getVoices() — speech synthesis
  • debouncedInput(inputElement, callback, delay?) — debounced input handler
  • runInParallel(tasks)Promise.all wrapper

Release Steps

# 1. Bump version
npm version patch   # or minor / major

# 2. Verify what will be published
npm run pack:dry

# 3. Publish to npm
npm publish --access public

# 4. Push tag to GitHub
git push && git push --tags

License

MIT © Peter Benoit