JSPM

undef-check

0.0.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q7210F
  • License MIT

Undefined or Null Checker.

Package Exports

  • undef-check
  • undef-check/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (undef-check) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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.