Skip to content

Latest commit

 

History

History
41 lines (31 loc) · 801 Bytes

README.md

File metadata and controls

41 lines (31 loc) · 801 Bytes

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.