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

@marasuchus/domain

v4.0.0

Published

Domain types and helpers: Result, Zod validation and pagination

Readme

@marasuchus/domain

Domain types and helpers, published as a public package on npmjs.com. ESM only, types included.

Installation

pnpm add @marasuchus/domain

zod is an optional peer: install it only if you use ./validation (see table below).

Modules

Each module is imported via subpath, with no barrel loading everything:

import { Result } from "@marasuchus/domain/result";

| Subpath | Status | Required peers | | -------------- | ----------- | -------------- | | ./result | implemented | none | | ./pagination | implemented | none | | ./validation | implemented | zod |

result

Result<T, E> models success or failure without throwing exceptions. DomainError is the union of ValidationError and NotFoundError.

import { Result } from "@marasuchus/domain/result";

const found = Result.ok(user);
const missing = Result.notFound("User not found", "User", id);
const invalid = Result.validation("Invalid input", { email: "Invalid email" });

if (!found.ok) {
  // found.error: DomainError
}

Result.err builds an arbitrary error when the E type is not DomainError.

pagination

Base types for paginated listings, plus the constant SortDirection derives from.

import {
  SORT_DIRECTION,
  type BaseQuery,
  type PaginatedResult,
  type SortDirection,
} from "@marasuchus/domain/pagination";

const page: PaginatedResult<{ id: number }> = {
  data: [{ id: 1 }],
  count: 42,
  page: 2,
  pageSize: 15,
  pageCount: 3,
};

validation

zod schemas and helpers for query params and forms: they all tolerate null, undefined, and empty strings (returning undefined or a default instead of failing).

  • sortDirSchema / sortDirDescSchema: "asc" | "desc", defaulting to "asc" / "desc" on invalid input.
  • optionalPositiveInt, optionalInt, optionalNumber: coerce strings to numbers; undefined when there is no value or it is invalid.
  • optionalTrue: only true, "true", or "1" return true; everything else is undefined (useful for checkboxes).
  • optionalDateOnly: accepts YYYY-MM-DD only.
  • optionalTextFilter: trim + 255 character max.
  • parseFormBoolean(value, fallback): parses "true"/"1" and "false"/"0", falling back to fallback for anything else.
  • createPaginatedQuerySchema(sortOptions, defaultSortBy, defaultSortDir, { defaultPageSize, maxPageSize }): valida page (default 1), pageSize (clamped a maxPageSize, default a defaultPageSize), sortBy y sortDir con sus defaults.
import {
  createPaginatedQuerySchema,
  optionalPositiveInt,
  sortDirSchema,
} from "@marasuchus/domain/validation";

const querySchema = createPaginatedQuerySchema(
  ["name", "createdAt"] as const,
  "name",
  "asc",
  {
    defaultPageSize: 15,
    maxPageSize: 100,
  },
);

License

MIT — see LICENSE.