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

zilla-util

v1.2.28

Published

Simple zero-dependency utility library

Readme

zilla-util

Simple utility library for TypeScript and modern JavaScript projects.

zilla-util provides small helpers for arrays, strings, dates, object traversal, retries, caches, hashing, URL cleanup, WebCrypto operations, and related application plumbing. The package is ESM-first and exports TypeScript declarations from its built output.

Installation

npm install zilla-util
pnpm add zilla-util

Usage

Import utilities from the package root:

import { retry, sleep, sluggize, LRUCache, deepGet } from "zilla-util";

const slug = sluggize("Hello, World!", "-");

const value = deepGet<string>(
    {
        user: {
            profile: {
                name: "Ada",
            },
        },
    },
    "user.profile.name"
);

const cache = new LRUCache<string, number>({ maxSize: 100, maxAge: 60_000 });
cache.set("answer", 42);

await retry(async () => {
    await sleep(100);
    return "ok";
});

The package also exposes a subpath export for array helpers:

import { containsAll } from "zilla-util/array";

What's Included

Arrays

  • Set and inclusion helpers: setsEqual, containsAll, isAnyTrue
  • Collection helpers: cartesianProduct, asyncFilter, shuffleArray, shuffleNumbers
  • Deduplication helpers: deduplicateArray, deduplicateArrayByName, firstByProperty
  • Sorted set classes: SortedSet, SortedIdSet

Strings and Formatting

  • Case and path helpers: capitalize, uncapitalize, basefilename, ext, basefilenameWithoutExt
  • Slug and case conversion helpers: sluggize, hyphenate, camel2kebab, camel2snake, kebab2camel, snake2camel
  • Date string helpers: dateAsYYYYMMDD, dateAsUTCYYYYMMDD, nowAsYYYYMMDD, dateAsYYYYMMDDHHmmSS
  • Token and ID helpers: uuidv4, randomSafeToken, randomSuperSafeToken, randomDigits
  • JSON and text helpers: safeStringify, sortedStringify, trimSpaces, countVisibleChars
  • ANSI and browser CSS style constants: ANSI, CSS

Dates and Time

  • UTC date formatter: formatDate
  • Clock abstraction: ZillaClock, DEFAULT_CLOCK, MockClock, mockClock
  • Async timing helpers: sleep, nap, delay
  • Duration parsing: parseSimpleTime, with values such as 500, 2s, 5m, 1h, and 1d

Deep Objects

  • Path parsing and traversal: parseDeep, deepGet, deepUpdate
  • Comparison helpers: deepEquals, deepAtLeastEquals, deepEqualsForFields
  • Object cleanup and filtering: stripNonAlphaNumericKeys, filterObject, filterProperties
  • Empty checks: isEmpty, isNotEmpty
  • Immutable proxy wrapper: immutify
  • Recursive transforms: copyWithRegExp, deepTransform

Deep paths support dot notation and array indexes:

import { deepGet, deepUpdate } from "zilla-util";

const obj = { users: [{ name: "Ada" }] };

deepGet<string>(obj, "users[0].name"); // "Ada"
deepUpdate(obj, "users[].name", "Grace"); // appends an object to users

Cache and Retry

  • LRUCache provides bounded in-memory caching with optional max age and touch-on-get behavior.
  • withLRUCache memoizes sync or async functions.
  • retry retries async functions with configurable attempts, exponential backoff, and retry filtering.
import { retry, withLRUCache } from "zilla-util";

const cachedLookup = withLRUCache(async (id: string) => {
    return fetch(`/api/items/${id}`).then((r) => r.json());
});

const result = await retry(() => cachedLookup("abc"), {
    maxAttempts: 5,
    backoffBaseMillis: 250,
    backoffMultiplier: 2,
});

Encoding, Hashing, and Crypto

  • URL-safe base64 helpers: base64Encode, base64Decode
  • SHA-256 helpers: sha256, shaLevels, dirLevels
  • WebCrypto RSA helpers: CryptoUtil.generateKeyPair, CryptoUtil.encrypt, CryptoUtil.decrypt, CryptoUtil.sign, CryptoUtil.verifySignature

CryptoUtil uses globalThis.crypto.subtle, so it requires a WebCrypto-capable runtime.

URLs

  • normalizeUrl normalizes valid URL strings with the platform URL implementation.
  • canonicalizeUrl lowercases protocol/host, removes common tracking parameters, follows redirects, and inspects HTML canonical metadata when available.

Other Utilities

  • substContext replaces {{variable}} placeholders in strings, arrays, and objects.
  • wrapError wraps unknown thrown values with contextual Error objects.
  • GenericLogger and DEFAULT_LOGGER define a small logger interface.
  • Message transport types are available through ZillaMsgTransportType, ZillaMessage, and ZillaMsgTransport.
  • packageVersion attempts to discover the nearest package.json version from an import URL.

Development

Install dependencies:

pnpm install

Build the package:

pnpm build

Run tests:

pnpm test

Run linting:

pnpm lint

Run the full release check:

pnpm release

License

Apache-2.0. See LICENSE.txt.