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

@a-box-of-scraps/ts-utils

v0.2.0

Published

A Box of Scraps's TypeScript utilities.

Readme

Utils

A Box of Scraps's TypeScript utilities.

Installation

npm install @a-box-of-scraps/ts-utils

The package ships compiled ESM and TypeScript declarations.

import { assertNever, isEnumValue, parseEnumValue, Result, type ValueOf } from "@a-box-of-scraps/ts-utils";

Utilities

This library provides the following utilities:

Enum

Use a frozen as const object to name string or number values. ValueOf<typeof Status> gives the union of its values, not its keys. The values are plain primitives, so they can be compared or sent in API payloads directly.

const Status = Object.freeze({ Enabled: "enabled", Disabled: 0 } as const);
type Status = ValueOf<typeof Status>; // "enabled" | 0

function readStatus(input: unknown): Status {
	return parseEnumValue(Status, input);
}

Use isEnumValue(Status, input) to narrow an unknown input to Status without throwing. Use parseEnumValue when an invalid value should throw a TypeError. Both check values without coercion: 0 is accepted, but "0" and the key "Disabled" are not.

Result

Result<Value, Failure> represents success or failure as a discriminated union. Create results with Result.ok(value) or Result.err(error), then check the ok property to access the corresponding value or error. Failures can be any type, not just Error instances, making expected failures explicit in return types.

Assert Never

assertNever(value) accepts only never to enforce exhaustive handling of unions. Call it in the default branch of a switch or after handling every case: an unhandled member produces a type error. If reached at runtime, it throws an error containing the unexpected value.

Examples

  • Enum: Restore a saved theme with a fallback, but reject an unsupported theme in a new settings request.
  • Explicit State: Model job transitions with literal values, return successes or failures with Result, and enforce exhaustive state handling with assertNever.

Changelog

All notable changes to this package are documented HERE.

License

Licensed under the MIT License by A Box of Scraps.