undef-check
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

undef-check

Undefined and Null Checker

npm i undef-check

import module

// ES6 Syntax
import {undefCheck} from "undef-check";

// Commonjs Syntax
const {undefCheck} = require("undef-check");

// Commonjs with custom name
const undefinedChecker = require("undef-check").undefCheck;

usage

undefCheck(possibleUndefinedVariable);

demo

let nullVariable = null;
let undefinedVariable = void 0;

undefCheck(undefinedVariable); // throws error with default message 

undefCheck(nullVariable, "Variable cannot be null."); // throws error with "Variable cannot be null." message  

undefCheck(-6.2342); // no errors

undefCheck("Hello, world"); // no errors

types

type undefCheck = (value: any, message?: string) => void; // throws Error.

Package Sidebar

Install

npm i undef-check

Weekly Downloads

1

Version

0.0.4

License

MIT

Unpacked Size

3.02 kB

Total Files

5

Last publish

Collaborators

  • jellybeanci