Undefined and Null Checker
npm i undef-check
// ES6 Syntax
import {undefCheck} from "undef-check";
// Commonjs Syntax
const {undefCheck} = require("undef-check");
// Commonjs with custom name
const undefinedChecker = require("undef-check").undefCheck;
undefCheck(possibleUndefinedVariable);
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
type undefCheck = (value: any, message?: string) => void; // throws Error.