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

dhi

v0.4.3

Published

Ultra-fast validation library - 1.78x faster than Zod. Drop-in replacement with WASM performance. Works with Next.js!

Readme

dhi - Ultra-Fast Validation for JavaScript/TypeScript

1.64x faster than Zod with 40.26M ops/sec in TURBO mode! 🚀

Drop-in replacement for Zod with WASM-powered performance.

Quick Start

npm install dhi
# or
bun add dhi

Basic Usage (Drop-in Zod Replacement)

import { z } from "dhi/schema";

// Works exactly like Zod!
const UserSchema = z.object({
  name: z.string().min(2).max(100),
  email: z.string().email(),
  age: z.number().positive().int(),
  role: z.enum(["admin", "user", "guest"]),
  tags: z.array(z.string()).optional()
});

// Validate single item
const user = UserSchema.parse({ name: "Alice", email: "[email protected]", age: 30, role: "user" });

// Safe validation
const result = UserSchema.safeParse(data);
if (result.success) {
  console.log(result.data);
} else {
  console.log(result.error);
}

TURBO Mode (Maximum Performance)

For simple schemas with string length and number range validations:

import { turbo } from "dhi/turbo";

// 40.26M ops/sec!
const schema = turbo.object({
  name: turbo.string(2, 100),
  age: turbo.number(18, 120)
});

// Validate thousands at once
const users = [/* ... 100K users ... */];
const results = schema.validateMany(users);

Batch API (8.19x faster on mixed data)

import dhi from "dhi";

const schema = {
  name: dhi.z.string(2, 100),
  email: dhi.z.email(),
  age: dhi.z.positive()
};

// Blazing fast on mixed valid/invalid data
const results = dhi.validateBatch(users, schema);

Performance

| Mode | ops/sec | vs Zod | Best For | |------|---------|--------|----------| | TURBO | 40.26M | 1.64x faster 🥇 | Simple schemas, maximum speed | | Batch (mixed data) | 15.76M | 8.19x faster 🔥 | Real-world data with errors | | Feature-complete | 7.14M | 0.66x | Full Zod compatibility |

Features

All Zod Features ✅

String Validators

  • min(), max(), length() - Length constraints
  • email(), url(), uuid() - Format validation
  • startsWith(), endsWith(), includes() - String checks
  • regex() - Custom patterns
  • trim(), lowercase(), uppercase() - Transformations

Number Validators

  • min(), max() - Range
  • gt(), gte(), lt(), lte() - Comparisons
  • positive(), negative(), nonnegative() - Sign checks
  • int(), finite() - Type constraints
  • multipleOf() - Divisibility

Composite Types

  • object() - Object schemas
  • array() - Array validation
  • union() - Multiple types
  • enum() - Enumerations
  • optional(), nullable() - Modifiers

Advanced

  • .transform() - Data transformation
  • .refine() - Custom validation
  • .default() - Default values
  • Type inference with z.infer<>

API Comparison

dhi (Drop-in Replacement)

import { z } from "dhi/schema";

// Works exactly like Zod!
const schema = z.object({
  name: z.string().email(),
  age: z.number().positive()
});

Zod

import { z } from "zod";

const schema = z.object({
  name: z.string().email(),
  age: z.number().positive()
});

Yes, it's that simple! Just change the import and you're done!

Migration from Zod

Option 1: Alias (Quickest)

// Old: import { z } from "zod";
import { z } from "dhi/schema";

// Everything else stays the same!

Option 2: Gradual Migration

// Keep using Zod where needed
import { z as zodz } from "zod";

// Use dhi for performance-critical paths
import { z } from "dhi/schema";
import { turbo } from "dhi/turbo";

When to Use Each API

Use TURBO Mode When:

  • ✅ Simple schemas (string length, number range)
  • ✅ Validating thousands of items
  • ✅ Maximum performance needed
  • ✅ Production workloads

Use Batch API When:

  • ✅ Mix of valid and invalid data
  • ✅ Need early-exit optimization
  • ✅ Real-world scenarios

Use Feature-Complete API When:

  • ✅ Need full Zod compatibility
  • ✅ Complex schemas with email, URL, UUID
  • ✅ Transformations and refinements
  • ✅ Detailed error messages

Real-World Example

import { z } from "dhi/schema";

// Financial data validation
const TradeSchema = z.object({
  tradeId: z.string().min(10).max(50),
  cusip: z.string().length(9),
  quantity: z.number().positive().int(),
  price: z.number().positive(),
  settlementDate: z.string(),
  counterparty: z.string().min(5)
});

// Validate 100K trades
const trades = [/* ... */];
const results = trades.map(t => TradeSchema.safeParse(t));

// Or use batch mode for even more speed
import dhi from "dhi";
const batchResults = dhi.validateBatch(trades, {
  tradeId: dhi.z.string(10, 50),
  cusip: dhi.z.string(9, 9),
  quantity: dhi.z.positive(),
  price: dhi.z.positive(),
  settlementDate: dhi.z.isoDate(),
  counterparty: dhi.z.string(5, 100)
});

Bundle Size

  • WASM module: 9.2KB (smaller than most validators!)
  • Tree-shakeable
  • Zero dependencies (WASM is included)

Browser Support

Works everywhere that supports WASM:

  • ✅ Chrome/Edge 57+
  • ✅ Firefox 52+
  • ✅ Safari 11+
  • ✅ Node.js 18+
  • ✅ Deno
  • ✅ Bun

TypeScript Support

Full TypeScript support with type inference:

import { z, infer as zodInfer } from "dhi/schema";

const UserSchema = z.object({
  name: z.string(),
  age: z.number()
});

type User = zodInfer<typeof UserSchema>;
// { name: string; age: number }

Benchmarks

Run benchmarks yourself:

git clone https://github.com/justrach/satya-zig.git
cd satya-zig/js-bindings
bun install
bun run benchmark-final.ts

Why dhi?

  1. 🚀 Blazing Fast: 1.64x-8.19x faster than Zod
  2. ✅ Zod Compatible: Drop-in replacement
  3. 🎯 Three APIs: Choose speed vs features
  4. 📦 Tiny: 9.2KB WASM
  5. 🌍 Universal: Works everywhere
  6. 🔒 Type-Safe: Full TypeScript support

License

MIT

Links


Made with Zig + WASM | धी means wisdom/intellect in Sanskrit 🧠