existjs
TypeScript icon, indicating that this package has built-in type declarations

2.1.0 • Public • Published

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

Package Sidebar

Install

npm i existjs

Weekly Downloads

0

Version

2.1.0

License

MIT

Unpacked Size

11.6 kB

Total Files

15

Last publish

Collaborators

  • webdevelopland