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 🙏

© 2025 – Pkg Stats / Ryan Hefner

typebolt

v0.7.0

Published

TypeScript static helpers

Downloads

136

Readme

https://github.com/kube/typebolt/actions?query=workflow%3ABuild+branch%3Amaster

TypeScript static helpers for types accuracy and testing

Install

yarn add --dev typebolt

Minimal TypeScript Version: 4.9

Content

Logical Operators

  • Not<T> : Logical Not
  • And<A, B> : Logical And
  • Or<A, B> : Logical Or
  • Xor<A, B> : Logical Exclusive Or
  • Nor<A, B> : Logical Not Or
  • Nand<A, B> : Logical Not And
  • Xnor<A, B> : Logical Exclusive Not Or
Not<true> // false
Not<false> // true

And<true, true> // true
And<true, false> // false
And<true, false> // false

Or<true, false> // true
Or<true, true> // true

// ...

Not<Or<true, false>> // false – Equivalent to Nor
Not<And<true, false>> // true – Equivalent to Nand

Testing Types

  • IsType<T, S>: S is a Subtype of T (a.k.a. extends)
  • IsUnion<T>: T an Union
  • IsAny<T>: T is any
  • IsExactType<T1, T2>: T1 and T2 are exact same.

Assert

Assert a Type is true or false.

import { value Assert } from "typebolt";

Assert<true>();
Assert<false>(); // ERROR
Assert<boolean>(); // ERROR

Assert.True<true>();
Assert.True<false>(); // ERROR
Assert.True<boolean>(); // ERROR

Assert.False<false>();
Assert.False<true>(); // ERROR
Assert.False<boolean>(); // ERROR

IsType<T, S>

Check S is subtype of T. (a.k.a. extends)

Assert<IsType<number, 42>>();
Assert<IsType<number, number>>();
Assert<IsType<42, number>>(); // ERROR

IsExactType<T1, T2>

Check T1 and T2 are exact same types.

Assert<IsExactType<42, 42>>();
Assert<IsExactType<any, 42>>(); // ERROR
Assert<IsExactType<number, 42>>(); // ERROR

// With unions
Assert<IsExactType<string | number, string | number>>();
Assert<IsExactType<string | number, string>>(); // ERROR
Assert<IsExactType<string, string | number>>(); // ERROR

// With any
Assert<IsExactType<any, any>>();
Assert<IsExactType<any, number>>(); // ERROR

Tuple Operations

  • Head<T>: First element of T
  • Tail<T>: All elements after head of T
  • Prepend<X, T>: Add element X in front of T
  • Append<X, T>: Add element X at end of T
  • Reverse<T>: Reverse T
  • Take<N, T>: Take N first elements of T
  • TakeLast<N, T>: Take N last elements of T
  • Drop<N, T>: Remove N first elements of T
  • DropLast<N, T>: Remove N last elements of T
Head<["Hello", "World"]> // "Hello"
Tail<["Hello", "World"]> // ["World"]

Prepend<1, [2, 3, 4]> // [1, 2, 3, 4]
Append<4, [1, 2, 3]> // [1, 2, 3, 4]
Reverse<[1, 2, 3, 4]> // [4, 3, 2, 1]

Take<2, [1, 2, 3, 4]> // [1, 2]
TakeLast<2, [1, 2, 3, 4]> // [3, 4]
Drop<2, [1, 2, 3, 4]> // [3, 4]
DropLast<2, [1, 2, 3, 4]> // [1, 2]

Caveat

  • boolean is always considered union of true | false.

  • Union of a Type T and a SubType S will resolve to non-union T.

    e.g. string | "Hello" resolves to string

  • Union with any will always resolve to any.