JSPM

existjs

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q16661F
  • 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

v1.0.0 ( last update: 9 dec 2017 )

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

Install

npm

npm install existjs --save

Node.js

const existjs = require('existjs');
// or
const { is, not, ... } = require('existjs');

Typescript

import * as existjs from 'existjs';
// or
import { is, not, ... } from 'existjs';

Browser

<script src='/node_modules/existjs/dist/existjs-min.js'></script>

is()

Is the variable exist?

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

not()

Not exist?

not(undefined); // true
// not(var) = !is(var)

or()

It chooses first existing variable

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

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