
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
is-not-null-or-undefined
Advanced tools
A TypeScript utility function to check if a value is not null or undefined
A TypeScript utility function & type-guard to check if a value is not null or undefined.
npm install is-not-null-or-undefined
yarn add is-not-null-or-undefined
pnpm add is-not-null-or-undefined
import { isNotNullOrUndefined } 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
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());
}
FAQs
A TypeScript utility function to check if a value is not null or undefined
We found that is-not-null-or-undefined demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.