Skip to content

jellybeanci/undef-check

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Releases

No releases published

Packages

No packages published