
Research
Malicious fezbox npm Package Steals Browser Passwords from Cookies via Innovative QR Code Steganographic Technique
A malicious package uses a QR code as steganography in an innovative technique.
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.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.
Application Security
/Research
/Security News
Socket detected multiple compromised CrowdStrike npm packages, continuing the "Shai-Hulud" supply chain attack that has now impacted nearly 500 packages.