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

@oxy.so/utils

v1.2.0

Published

Dependency-free helpers shared across every Oxy service — SQL LIKE-pattern escaping, page-window clamping, and the small pure functions that were being copied between repos.

Readme

@oxy.so/utils

Dependency-free helpers shared across every Oxy service.

What belongs here

A helper earns a place only if it is all three of:

  1. copied byte-identically into three or more repos,
  2. pure and dependency-free,
  3. something no repo could reasonably want a different version of.

The third clause does most of the work. An audit of eight Oxy repos found plenty of duplication that fails it and is deliberately not here:

| Candidate | Repos | Why not | |---|---|---| | Query-param coercion | 3 | All three chose contradictory semantics for a repeated parameter — absent (Mention), last wins (oxy), first wins (Homiio) — and each documents its choice as the fix for a real incident. One shared version would overrule two of them. | | Retry / backoff | 5 | Six different policies. A retry budget is a decision about a specific dependency. | | Compact number / duration formatting | 4 | Four different outputs (1.2K vs 482.8k). Unifying them is a design change. | | sleep / delay | 4 | Six of seven copies leak a timer on cancellation. Sharing would enshrine the bug; the good one is AbortSignal-aware and belongs with the HTTP client. |

The ecosystem also has a binding precedent for leaving small things duplicated: ADR 0022 keeps per-app i18n rather than sharing one catalogue, because the shared version would carry the wrong weight. A utility that has to be configured into agreement is that case.

Exports

Nominal, following @oxy.so/core: no export *, no barrels. Subpaths exist because two consumers' bundle gates refuse root-barrel imports — Metro does not tree-shake, so a frontend importing one function must reach it without dragging the rest in.

import { likeContains }      from '@oxy.so/utils/sql';
import { resolvePageLimit }  from '@oxy.so/utils/paging';
import { escapeRegExp }      from '@oxy.so/utils/text';
import { calendarDaysBetween } from '@oxy.so/utils/date';
import { withImageVariant }    from '@oxy.so/utils/image';

./sql — LIKE pattern building

escapeLikePattern, likeContains, likeStartsWith, likeEndsWith.

Found ten times in six repos, six byte-identical, with one test between all six. The escaping is the security-relevant half: a term reaching LIKE unescaped means 100% matches every row, and nothing in the response says the filter was ignored. This does not defend against injection — the term is always a bound parameter — only against the caller's text being read as a pattern.

./paging — page-window resolution

resolvePageLimit, resolvePageOffset, resolvePageNumber, offsetForPage.

Seven helpers in five repos plus 46 inline clamps, none agreeing on degenerate input. The guarantee: no input — missing, malformed or hostile — yields an unbounded query or a NaN. Bounds are arguments, not a registry: a lane's page size belongs next to the lane.

./text — small pure helpers

escapeRegExp (16 byte-identical copies across four repos), clamp (with the NaN guard two of three copies had), chunk.

./date — calendar-day arithmetic

calendarDaysBetween(from, to): whole LOCAL calendar days, 0 same day, 1 next, -1 previous, time of day ignored.

The "Today / Yesterday / this week" bucketing is hand-written in six repos as (startOfDay(a) - startOfDay(b)) / 86400000. Two (Inbox ×4, oxy's accounts activity list) round it with Math.floor, which is wrong across a spring-forward night: midnight-to-midnight is 23 hours, floors to 0, and yesterday's mail files under "Today". This subtracts the date parts as UTC dates, where every day is 24 hours. It answers which calendar day, not how much time elapsed — elapsed-time labels ("2d ago") stay where they are. An invalid Date yields NaN, which fails every === 0 / < 7 comparison.

Consuming it

Inside this monorepo, workspace:. From another repo, the published semver range — and note that a repo with no prior @oxy.so/utils dependency needs it added to its manifest and its lockfile regenerated; --frozen-lockfile does not catch a manifest/lock desync on its own.

Commands

bun run test        # never a bare `bun test`
bun run typescript
bun run lint
bun run build