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

@typepurify/types

v0.5.7

Published

Advanced TypeScript utility types and helpers.

Readme


npm version License: MIT

🚀 Overview

@typepurify/types provides a zero-dependency collection of deeply nested utility types and runtime helpers that enforce strict type constraints. Designed to compliment the TypePurify ecosystem, it includes everything from recursive omit/merge types to safe deep path extractors (get()).

📦 Installation

npm install @typepurify/types

🛠 Features & Examples

1. Advanced Structural Types

DeepRequired<T> & DeepPartial<T> Recursively makes all properties of an object (and nested objects/arrays) either required or optional.

import type { DeepRequired, DeepPartial } from '@typepurify/types';

type Config = { api?: { key?: string; timeout?: number } };

// Enforces all nested properties to be defined
type StrictConfig = DeepRequired<Config>;
// => { api: { key: string; timeout: number } }

DeepOmit<T, K> Deeply removes keys from an object at any nesting level.

import type { DeepOmit } from '@typepurify/types';

type Payload = { user: { id: string; secret: string }; secret: string };
type SafePayload = DeepOmit<Payload, 'secret'>;
// => { user: { id: string } }

DeepReadonly<T> Recursively locks an object making all its nested properties immutable.

import type { DeepReadonly } from '@typepurify/types';
const state: DeepReadonly<{ data: { items: string[] } }> = { data: { items: ['A'] } };
// state.data.items.push('B') // TS Error!

DeepMerge<T, U> Recursively merges two structural types together, resolving nested properties intelligently.

RequireAtLeastOne<T, Keys> Enforces that at least one of the specified properties must be provided.

import type { RequireAtLeastOne } from '@typepurify/types';

type Target = RequireAtLeastOne<{ id: string; email: string }, 'id' | 'email'>;
// Valid: { id: "123" }
// Valid: { email: "[email protected]" }
// Invalid: {}

2. String & Literal Utilities

SnakeToCamelCase<S> Converts a snake_case literal string type to camelCase.

import type { SnakeToCamelCase } from '@typepurify/types';
type Camel = SnakeToCamelCase<'user_first_name'>; // "userFirstName"

3. JSON Utilities

Strict types for valid JSON structures:

  • JsonValue, JsonPrimitive, JsonArray, JsonObject

4. Runtime Helpers

This package also exports lightweight runtime functions that compliment the types.

get<T>(obj, path, defaultValue) A safe, lightweight deep property extractor that handles array and string notations safely.

import { get } from '@typepurify/types';

const data = { users: [{ profile: { name: 'Alice' } }] };

// Safe extraction without "cannot read properties of undefined"
const name = get(data, 'users[0].profile.name', 'Unknown');
console.log(name); // "Alice"

jsonToTsType(json) Generates a raw TypeScript type string representation from a JSON object at runtime.

import { jsonToTsType } from '@typepurify/types';
console.log(jsonToTsType({ id: 1, active: true }));
// => "{ id: number; active: boolean; }"

🆕 New in v0.5.8

asDeepPartial<T>(value) — Zero-Cost Deep Partial Cast

Casts any unknown value to DeepPartial<T> at compile time — no runtime cost.

import { asDeepPartial } from '@typepurify/types';

const partial = asDeepPartial<User>({ name: 'Alice' });
// partial.name => "Alice" | undefined

evaluateMathOperator(a, op, b) — Type-Safe Math

Type-safe numeric operator evaluator using the MathOperator type.

import { evaluateMathOperator } from '@typepurify/types';

evaluateMathOperator(10, '+', 5); // 15
evaluateMathOperator(10, '/', 0); // NaN

🛡️ License

MIT © Vallarasu Kanthasamy


📋 Changelog

v0.5.4 — Latest

New Features:

  • RegexMatchLiteral<S, Pattern> — Type-level utility that extracts literal string pattern matches from a string type as a union type.
import type { RegexMatchLiteral } from '@typepurify/types';

type Matches = RegexMatchLiteral<'hello_world_test', 'world'>;
// => 'world'

Bug Fixes:

  • Prototype pollution guard added to get() path helper — paths containing __proto__, constructor, or prototype now throw safely.

v0.5.1

  • Added RequireAtLeastOne<T>, MakeOptional<T, K>, MakeRequired<T, K>, DeepRequiredStrict<T>, Writable<T>.