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

@nirelc/microtype

v0.0.1

Published

Super lightweight and simple type system library

Readme

microtype

Super lightweight and simple type system library like zod, but faster, smaller, and with fewer functions.

We doesn't use eval, Function or something like this, because we're staying web-friendly

Install

NPM

npm install @nirelc/microtype

Bun

bun intall @nirelc/microtype

Usage

Imports

Microtype can be imported with wildcard or with only required types

// with only required types import
import { … } from '@nirelc/microtype';

// with a wildcard import
import * as t from '@nirelc/microtype';

Your first type

Microtype simillar with valibot and other type system libs, because of this, you will easily understand our syntax

import { object, string } from "@nirelc/microtype";

// typescript
type UserData = {
  username: string;
  email?: string;
};

// microtype
const PostSchema = object({
  username: string(),
  email: string().optional(),
});

type PostData = typeof PostSchema.static;

const data = PostSchema.parse({
  username: "system",
  should: "strip",
});

We provide some useful features with schema chaining

const PostSchema = object({
  email: string().min(5).max(128).optional(),
  version: number().default(1),
});

API

All types support <type>.default(<value>) syntax.

Now we support these types:

String

// typescript
type Username = string;

// microtype
const UsernameSchema = string();

// extra fields
const UsernameExtraSchema = string().min(1).max(24).default("root");

Numbers

// typescript
type Version = number;

// microtype
// any number and floats
const VersionSchema = number(); // or `float()` as alias

// only integer (float will trigger error)
const VersionIntSchema = integer();

// integer with pre-built validators
// supports: uinteger, u8, u16, u32, i8, i16, i32
const SmallVersionSchema = u8();

// extra fields
// e.g value should equals 1 <= value <= 3 and should parse string as number and drop float support
const VersionExtraSchema = number().min(1).max(3).coerce(true).integer(true);

Literal

// typescript
type Username = "root";

// microtype
const UsernameSchema = literal("root");

Optional

Supported separated type optional(<schema>), also can be chained with <schema>.optional()

// typescript
type Email = string | undefined;

// const EmailSchema = string().optional()
const EmailSchema = optional(string());

Unions

// typescript
type Username = "root" | "user";

// microtype
const UsernameSchema = union([literal("root"), literal("user")];

// with nested union
const UsernameWithNestedSchema = union([literal("root"), union([literal("user")])])

Arrays

// typescript
type Versions = number[];

// microtype
const VersionsSchema = array(number());

// extra fields
// min 1 item, max 3 items
const VersionsLimitedSchema = array(number()).min(1).max(3);

// array.length should be equal 3
const VersionsWithLengthScheam = array(number()).length(3);

Objects

All unknown fields will be deleted

// typescript
type User = {
  username: string;
  email?: string;
  status: "banned" | "active";
};

// microtype
const VersionsSchema = object({
  username: string(),
  // email: string().optional()
  email: optional(string()),
  status: union([literal("banned"), literal("active")]),
});

Benchmarks

You can run benchmarks in bench dir.

Results

Cold start

Cold start (create a new schema and parse it)

| name | avg | | --------------- | --------- | | microtype | 649.81 µs | | valibot | 3.23 ms | | typebox | 18.34 ms | | arktype | 47.28 ms | | zod | 94.78 ms |

Global schema

Global schema (parsing with pre-created schema)

| name | avg | | ---------------------- | --------- | | typebox [compiled]* | 22.19 µs | | arktype* | 35.63 µs | | microtype | 382.47 µs | | valibot | 434.18 µs | | zod | 426.60 µs | | typebox | 6.26 ms |

* - arktype and typebox [compiled] uses precompile, because of this, it has better performance for global schema

Bundle size

We using a micro test case for create a type object schema + parse for all libs

| name | avg | | --------------- | --------- | | microtype | 9.02 KB | | valibot | 13.69 KB | | zod | 138.03 KB | | arktype | 281.49 KB | | typebox | 358.11 KB |

Why

Q: Why did you make another type system lib?

  • idk, just for fun