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

@niche-works/types

v0.3.2

Published

`@niche-works/types` is a niche library of TypeScript utility types.

Downloads

696

Readme

@niche-works/types

@niche-works/types is a niche library of TypeScript utility types.

日本語のREADMEはこちら

Installation

npm install @niche-works/types

Type Reference

Value state types

| Type | Definition | Description | | --------- | ---------------------------------------- | --------------------------------- | | Nullish | undefined \| null | null or undefined | | Empty | Nullish \| '' | Nullish plus empty string | | Falsy | Empty \| false \| 0 \| -0 \| 0n \| NaN | All JavaScript falsy values |

Record types

Generic record types whose keys are PropertyKey (string | number | symbol).

| Type | Definition | Description | | ------------------- | ------------------------- | ---------------------------------------------------- | | FlexibleRecord<V> | Record<PropertyKey, V> | Base type with a generic value type | | LooseRecord | FlexibleRecord<any> | Flexibility-first type that accepts any value type | | StrictRecord | FlexibleRecord<unknown> | Safety-first type that requires a type guard to use |

Dictionary types

Record types whose keys are string only.

| Type | Definition | Description | | ----------------------- | ----------------------------- | ---------------------------------------------------- | | FlexibleDictionary<V> | Record<string, V> | Base type with a generic value type | | LooseDictionary | FlexibleDictionary<any> | Flexibility-first type that accepts any value type | | StrictDictionary | FlexibleDictionary<unknown> | Safety-first type that requires a type guard to use |

Array types

| Type | Definition | Description | | ------------- | ----------- | -------------------------------------------------------- | | LooseArray | any[] | Flexibility-first array type that accepts any element | | StrictArray | unknown[] | Safety-first array type that requires a type guard to use |

Synchronous function types

| Type | Description | | ---------------------------------- | ------------------------------------------------------------ | | SyncFunction<P extends any[], R> | Base type with configurable parameter type P and return type R | | SyncLooseFunction | Flexibility-first type with any parameters and return value | | SyncStrictFunction | Safety-first type with never[] parameters and unknown return value |

Asynchronous function types

| Type | Description | | ----------------------------------- | --------------------------------------------------------------------- | | AsyncFunction<P extends any[], R> | Base type with configurable parameter type P and return Promise<R> | | AsyncLooseFunction | Flexibility-first type with any parameters and return value | | AsyncStrictFunction | Safety-first type with never[] parameters and Promise<unknown> return value |

Iteratee types

| Type | Signature | Description | | ----------------------- | ----------------------------------------------------------------- | ---------------------------------------- | | IndexedIteratee<V, R> | (value: V, index: number, data: V[]) => R | Callback for iterating over arrays | | KeyedIteratee<V, R> | (value: V, key: PropertyKey, data: Record<PropertyKey, V>) => R | Callback for iterating over objects |

Advanced utility types

Keys<RECORD, TYPE>

Generates a union type of the keys of a record. When TYPE is specified, only keys whose values extend that type are included.

import type { Keys } from '@niche-works/types';

type Props = {
  id: number;
  name: string;
  label: string;
  createdAt: Date;
};

// Union of all keys
type AllKeys = Keys<Props>;
// => 'id' | 'name' | 'label' | 'createdAt'

// Only keys whose value is string
type StringKeys = Keys<Props, string>;
// => 'name' | 'label'

Prefixed<PREFIX, RECORD, KEYS>

Generates a new type by prepending a camelCase prefix to the specified properties of a record.
When KEYS is omitted, all properties are targeted.

import type { Prefixed } from '@niche-works/types';

type Props = {
  width: number;
  height: number;
  color: string;
};

// Prefix all properties
type PrefixedProps = Prefixed<'default', Props>;
// => { defaultWidth: number; defaultHeight: number; defaultColor: string }

// Prefix only selected properties
type PartialPrefixedProps = Prefixed<'default', Props, 'width' | 'height'>;
// => { defaultWidth: number; defaultHeight: number; color: string }

PrefixedUnion<PREFIX, UNION, KEYS>

Generates a new union type by prepending a camelCase prefix to the members of a union.
When KEYS is omitted, all members are targeted.

import type { PrefixedUnion } from '@niche-works/types';

type Direction = 'top' | 'right' | 'bottom' | 'left';

// Prefix all members
type PaddingKeys = PrefixedUnion<'padding', Direction>;
// => 'paddingTop' | 'paddingRight' | 'paddingBottom' | 'paddingLeft'

// Prefix only selected members
type PartialMarginKeys = PrefixedUnion<'margin', Direction, 'top' | 'bottom'>;
// => 'marginTop' | 'right' | 'marginBottom' | 'left'

License

MIT