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

@lightbase/utils

v1.4.0

Published

Various utilities, some lodash like, some to aid with strict TypeScript. Also includes various type utilities.

Readme

@lightbase/utils

Various utilities, some lodash like, some to aid with strict TypeScript. Also includes various type utilities.

Utilities

This library exports the utility functions in the following groups:

Assertion functions

Type-narrowing assertions, that throw when the provided value is falsy. This uses TypeScript assert operator.

assertIsNil

Asserts that the provided value is null or undefined. Else throws the provided error.

assertNotNil

Asserts that the provided value is not null or `undefined. Else throws the provided error.

'Is' functions

Type-narrowing functions, returning truthy when the value is of the corresponding type. These can be used to constrain type in if-else branches.

isNil

Returns true when the provided value is null or undefined.

isRecord

Returns true when the provided value is an object-like.

isRecordWith

Returns true when the provided value is an object-like and has the provided keys.

Invariants

Generic assertion functions that don't type-narrow. Can be used to create business-specific validation functions to align business logic and related error return types.

[!INFO]

If at some point TypeScript supports creating assertion functions via a generic function, without manually typing the resulting assertion, this system will be applied to asserts as well.

createInvariant

Create an invariant function to execute business rules. Various options are supported:

  • A predicate callback which is executed to determine if an invariant fails
  • Various options for error customization:
    • Static error messages.
    • Customizable error messages on invariant invocation.
    • A custom error constructor, function or static method with typed arguments on invariant invocation.
    • Partial application of the provided custom error.

Types

This library exports the following utility types:

Prettify

Force TypeScript to resolve the result of computed types. Can be used to improve the readability in Quick-documentation popups and errors.

MaybePromise and MaybeArray

Represent a value which may be wrapped in a Promise or Array respectively.

ExtractPromise and ExtractArray

Extract the type wrapped in a MaybePromise or MaybeArray respectively.

Brand

Brand types, so a general type like string is not assignable to a business constrainted type like 'email' without going through an explicit cast. See the Zod docs or the Total TypeScript article on this subject.

PickKeysThatExtends and OmitKeysThatExtend

Like Pick and Omit, but instead of specifying keys, specify the type of value that should be picked or omitted.

UnionToIntersection

Map union types to an intersection type.

InferFunctionLikeParameters

Extract the parameter types from class constructors or functions.

Node.js

This package has a specific @encapsula/util/node export providing the following utilities

createAsyncLocalStorage

Wrapper around AsyncLocalStorage, for read-only AsyncLocalStorage use. The main difference is the explicit get and getOptional functions that wrap AsyncLocalStorage#getStore. get, throws an error when not in the async-context of a store.