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

@bestcodetools/generic-types

v0.0.1

Published

Welcome to the Generic Types library! This library provides a set of generic types designed to help you work with TypeScript efficiently. Below you'll find a list of exported types, their purposes, and usage examples.

Readme

Generic Types Library

Welcome to the Generic Types library! This library provides a set of generic types designed to help you work with TypeScript efficiently. Below you'll find a list of exported types, their purposes, and usage examples.

Exported Types

ArrayElement

Purpose: Extracts the type of elements within an array type. This is useful when you need to work with the individual elements of an array and want to ensure type safety.

Usage Example:

type NumberArray = number[];
type NumberElement = ArrayElement<NumberArray>; // number

const element: NumberElement = 3; // Valid assignment

Awaited

Purpose: Unwraps the type of a promise to get the resolved value type. This is useful when working with asynchronous functions to ensure type safety for the resolved values.

Usage Example:

type PromiseNumber = Promise<number>;
type ResolvedNumber = Awaited<PromiseNumber>; // number

async function getNumber(): PromiseNumber {
  return 42;
}

const number: ResolvedNumber = await getNumber(); // Valid assignment

UnionToIntersection

Purpose: Converts a union type into an intersection type. This is useful when you want to merge multiple types into a single type with all the properties of the original types.

Usage Example:

type A = { a: string };
type B = { b: number };
type C = { c: boolean };

type ABC = UnionToIntersection<A | B | C>; // { a: string } & { b: number } & { c: boolean }

const example: ABC = {
  a: "Hello",
  b: 42,
  c: true
};

Mutable

Purpose: Makes all properties of a given type mutable. This is useful when you need to modify properties of an object that are otherwise read-only.

Usage Example:

type ReadonlyObject = {
  readonly name: string;
  readonly age: number;
};

type MutableObject = Mutable<ReadonlyObject>;

let person: MutableObject = {
  name: "Alice",
  age: 30
};

person.name = "Bob"; // This is allowed because the properties are now mutable.

MutableKeys

Purpose: Extracts the keys of a type that are mutable. This can be used to determine which properties of an object can be modified.

Usage Example:

type Sample = {
  readonly id: number;
  name: string;
  age: number;
};

type MutableKeysOfSample = MutableKeys<Sample>; // "name" | "age"

const mutableKeys: MutableKeysOfSample = "name"; // Valid assignment

ReadonlyKeys

Purpose: Extracts the keys of a type that are read-only. This is useful for identifying properties that cannot be modified.

Usage Example:

type Sample = {
  readonly id: number;
  name: string;
  age: number;
};

type ReadonlyKeysOfSample = ReadonlyKeys<Sample>; // "id"

const readonlyKeys: ReadonlyKeysOfSample = "id"; // Valid assignment

Installation

To use this library, install it via npm:

npm install @bestcodetools/generic-types

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

This project is licensed under ISC License.


Enjoy using the Generic Types library!