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

inu-light

v1.0.2

Published

A ultra-lightweight TypeScript validation library with zero dependencies.

Readme

inu-light

A lightweight, zero-dependency schema validation library for TypeScript. Designed to improve runtime data safety with schema-driven validation and strict avoidance of the any type.

Design philosophy

Most schema libraries are either heavy or rely on opaque runtime magic. inu-light is intentionally minimal and predictable: the schema is the single source of truth. Advanced TypeScript generics provide precise inference, so external data cannot silently break your types at runtime.

  • Zero Dependencies: minimal footprint, no runtime bloat

  • True Type Safety: no any in the inference engine

  • Runtime Validation: Strict validation for primitives and nested object structures

  • ESM Native: optimized for Vite, Webpack 5, and Next.js

Complex Types & Modifiers

  • inu.object(shape): Validates an object based on the provided shape.
  • inu.array(schema): Validates an array of elements matching the schema.
  • inu.union([schema1, schema2]): Validates that the input matches at least one of the provided schemas.
  • inu.literal(value): Validates an exact value (string, number, or boolean).
  • .optional(): Modifier to allow undefined.
  • .nullable(): Modifier to allow null.

Installation

npm install inu-light

Usage

1. Basic Example

The library uses the .parse() method to validate data. Instead of throwing unpredictable exceptions, it returns a result object containing either the validated data or a clear error message.

import { inu } from 'inu-light';

const UserSchema = inu.object({
  username: inu.string(),
  priority: inu.number(),
  isAdmin: inu.boolean(),
});

const result = UserSchema.parse(apiResponse);

if (result.success) {
  // TypeScript automatically knows 'result.value' type
  console.log(result.value.username);
} else {
  console.error('Validation failed:', result.error);
}

2. Complex Types & Modifiers

inu-light handles real-world data structures with ease:

  • Optional & Nullable: Explicitly allow undefined or null values.

  • Unions: Validate input against multiple possible schemas.

  • Literals: Enforce exact values (perfect for status codes or specific flags).

const ProjectSchema = inu.object({
  id: inu.string(),
  description: inu.string().optional(), // Accepts string | undefined
  status: inu.union([inu.literal('open'), inu.literal('closed')]),
  tags: inu.array(inu.string()).nullable(), // Accepts string[] | null
});

3. Type Inference (The "No Any" Rule)

Avoid redundancy. You don't need to manually write interfaces; the schema generates them for you.

import { inu, ShapeToType } from 'inu-light';

const ProductSchema = inu.object({
  sku: inu.string(),
  price: inu.number(),
});

// Automatically extract the TypeScript type
type Product = ShapeToType<typeof ProductSchema>;

// Resulting type: { sku: string; price: number; }

Type Inference

You can extract the TypeScript type directly from a schema using ShapeToType.

import { inu, ShapeToType } from 'inu-light';

const schema = inu.object({
  id: inu.number(),
});

type User = ShapeToType<typeof schema>;

API Reference

Primitives

| Method | Description | | :-------------- | :-------------------- | | inu.string() | Validates a string | | inu.number() | Validates a number | | inu.boolean() | Validates a boolean |

Structural

| Method | Description | | :-------------------- | :---------------------------------------------------------- | | inu.object(shape) | Validates an object based on the provided shape. | | inu.array(schema) | Validates an array where every item matches the schema. | | inu.tuple([s1, s2]) | Validates a fixed-length array with positional types. | | inu.union([s1, s2]) | Validates if the input matches at least one of the schemas. | | inu.literal(value) | Validates strict equality against the provided value. |

Modifiers (Available on all schemas)

  • .optional(): Transforms the type to T | undefined.
  • .nullable(): Transforms the type to T | null.

Development

# Install dependencies
npm install

# Build (Outputs to /dist)
npm run build

# Run local tests
npx tsx test-local.ts

Build

To compile the library from source:

npm run build

License

MIT