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

@kiruse/metatypes

v0.1.1

Published

Additional useful general-purpose MetaTypes for type manipulation & mapping.

Readme

MetaTypes.ts

Additional useful general purpose MetaTypes for type manipulation & mapping.

No dependencies other than TypeScript.

Note: I will add more meta types as my need for them arises.

Table of Contents

Installation

Install via npm:

npm i --save-dev @kiruse/metatypes

or via yarn:

yarn add @kiruse/metatypes

Usage

All exports of this package are type definitions. While usually negligible, it's advised to import type like such:

import type { Retype } from '@kiruse/metatypes';

import type allows importing type definitions only relevant to the compilation process. The TypeScript compiler (tsc) can thus completely remove these imports from the compiled JavaScript sources. MetaTypes hence becomes a vanity dependency.

Types

Defined<T>

Removes undefined and null from T. It is similar in nature to TypeScript's built-in Required.

Note: TypeScript will only complain about values being potentially null or undefined with the strictNullCheck compiler option enabled.

Example:

type SomeType = string | undefined | null;

var myGlobal: SomeType = undefined;

// Enforces that `v` must not be `undefined` or `null`.
function set(v: Defined<SomeType>) {
  myGlobal = v;
}

DefinedProps<T, P extends keyof T = keyof T>

Removes undefined and null from all (named) properties of T.

Differs from TypeScript's built-in Required in that Required only removes the "optional/omittable" flag from the property, whereas DefinedProps removes this flag as well as undefined and null from the type.

Note: TypeScript will only complain about values being potentially null or undefined with the strictNullCheck compiler option enabled.

Example:

type MyType = {
  foo?: number | null;
}
// equivalent to
type MyType = {
  foo: number | undefined | null;
} | {};

type MyRequiredType = Required<MyType>;
// equivalent to
type MyRequiredType = {
  foo: number | null;
}

type MyDefinedPropsType = DefinedProps<MyType>;
// equivalent to
type MyDefinedPropsType = {
  foo: number;
}

Prefix<T, P extends string>

Prefix all properties of T with P, retaining their original type. The properties will be capitalized to adhere to camel-casing.

Example:

type MyType = {
  foo: string;
  bar: number;
}

type Prefixed = Prefix<MyType, 'on'>;
// equivalent to
type Prefixed = {
  onFoo: string;
  onBar: number;
}

Retype<O, T, K extends keyof O = keyof O>

Map properties of O to new type T, optionally filtered to only properties specified by K.

Example:

type MyType = {
  foo: string;
  bar: number;
}

type MyTypeBool = Retype<MyType, boolean>;
// equivalent to
type MyTypeBool = {
  foo: boolean;
  bar: boolean;
}

type SelectiveRetype = Retype<MyType, symbol, 'bar'>;
// equivalent to
type SelectiveRetype = {
  foo: string;
  bar: symbol;
}

ExtractByPrefix<T, P extends string>

Extract a subtype of T which contains only (string) properties prefixed with P.

Example:

type MyType = {
  foo: string;
  onFoo: Function;
  bar: number;
  onBar: Function;
};

type MyEvents = ExtractByPrefix<MyType, 'on'>;

const events: MyEvents = {
  onFoo: () => {},
  onBar: () => {},
  bar: 42, // TSC issue!
};