JSPM

existjs

2.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q16668F
  • License MIT

Check variable existence

Package Exports

  • existjs

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 (existjs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

existjs

v2.1.0 ( last update: 20 mar 2018 )

Does the variable exist and what is its type? The easy way to know. Typescript included.

Install

npm

npm install existjs --save

Node.js

const { exist, or, ... } = require('existjs');

Typescript

import { exist, or, ... } from 'existjs';

Browser

<script src='/node_modules/existjs/dist/existjs-min.js'></script>
<script>
  // How to use:
  // existjs.exist();
  // existjs.or();
  // ...
</script>

exist()

Does the variable exist?

exist(null); // false
exist(undefined); // false
exist(NaN); // false
exist(0); // true
exist(''); // true
exist([]); // true
exist({}); // true
exist(false); // true
exist('hello'); // true

or()

It chooses first existing variable

var c = or(null, null, undefined, 72, 12, null, 'hi'); // c = 72
var c = or(undefined, 0, 2); // c = 0

Check types

isObject({ age: 99 }); // true
isNumber(122); // true
isString('deal with it'); // true
isArray([ 1, 2, 3 ]); // true
isFunction(function() {}); // true
isBoolean(false); // true