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

is-not-null-or-undefined

v2.0.0

Published

TypeScript predicates and type guards for nullish values, booleans, non-empty values, and renderable React nodes

Downloads

297

Readme

is-not-null-or-undefined

TypeScript predicates and type guards for nullish values, booleans, non-empty values, non-blank strings, and renderable React nodes.

Installation

npm

npm install is-not-null-or-undefined

yarn

yarn add is-not-null-or-undefined

pnpm

pnpm add is-not-null-or-undefined

Usage

import {
  isNotNullOrUndefined,
  isNotNullOrUndefinedAndFalse,
  isNotNullOrUndefinedAndNotBlank,
  isNotNullOrUndefinedAndNotEmpty,
  isNotNullOrUndefinedAndTrue,
  isNullOrUndefinedOrFalse,
} from 'is-not-null-or-undefined';

// Returns true for non-`null` and non-`undefined` values
isNotNullOrUndefined('string'); // true
isNotNullOrUndefined(123); // true
isNotNullOrUndefined({}); // true
isNotNullOrUndefined([]); // true
isNotNullOrUndefined(false); // true
isNotNullOrUndefined(0); // true

// Returns false for `null` and `undefined` values
isNotNullOrUndefined(null); // false
isNotNullOrUndefined(undefined); // false

// Checks strings, arrays, and array-like values by length
isNotNullOrUndefinedAndNotEmpty('value'); // true
isNotNullOrUndefinedAndNotEmpty('   '); // true
isNotNullOrUndefinedAndNotEmpty(''); // false
isNotNullOrUndefinedAndNotEmpty([1]); // true
isNotNullOrUndefinedAndNotEmpty([]); // false

// Checks strings after trimming
isNotNullOrUndefinedAndNotBlank(' value '); // true
isNotNullOrUndefinedAndNotBlank('   '); // false

// Checks boolean values
isNotNullOrUndefinedAndTrue(true); // true
isNotNullOrUndefinedAndTrue(false); // false
isNotNullOrUndefinedAndFalse(false); // true
isNullOrUndefinedOrFalse(null); // true
isNullOrUndefinedOrFalse(false); // true
isNullOrUndefinedOrFalse(true); // false

Type Guard

The function acts as a TypeScript type guard, narrowing the type from T | null | undefined to T:

const value: string | null | undefined = getValue();

if (isNotNullOrUndefined(value)) {
  // value is now typed as string
  console.log(value.toUpperCase());
}

React Subpath

import { hasRenderableNode } from 'is-not-null-or-undefined/react';

hasRenderableNode('value'); // true
hasRenderableNode(0); // true
hasRenderableNode([null, 'value']); // true
hasRenderableNode(new Set([false, 'value'])); // true
hasRenderableNode(''); // false
hasRenderableNode(true); // false
hasRenderableNode(false); // false
hasRenderableNode([]); // false
hasRenderableNode(new Set([false, true, ''])); // false
hasRenderableNode(null); // false
hasRenderableNode(undefined); // false

The /react subpath has no React runtime dependency. It imports ReactNode as a type only. TypeScript consumers of this subpath should have React types installed. hasRenderableNode returns a boolean predicate rather than a TypeScript type guard.

Migrating from v1 to v2

Version 2 is ESM-only and supports Node.js >=22.14.0. Import helpers by name from the package root or from the /react subpath.

import { isNotNullOrUndefined } from 'is-not-null-or-undefined';
import { hasRenderableNode } from 'is-not-null-or-undefined/react';

Default imports are not supported. Use the named isNotNullOrUndefined export instead.

The root entrypoint now includes focused helpers for non-empty values, non-blank strings, boolean guards, and false | null | undefined checks. React-specific render checks live behind the /react subpath so the root runtime stays React-free.

Agent-Assisted Adoption

This package includes an optional Agent Skill for reviewing a codebase for checks that may be clearer with these utilities.

Skill path:

skills/find-nullish-utils/SKILL.md

You can ask a coding agent to use that skill when reviewing nullable checks, boolean/nullish checks, empty string checks, array length checks, or React render guards.

The skill is guidance, not an automatic codemod. Suggested changes should still be reviewed for local semantics before applying them.