Simple is() function for typechecking
npm install arc-isA simple, efficient but comprehensive typechecking suite
In addition to native typechecking, it provides reliable behavior for:
* [ES6 new globally available constructor types] (http://www.ecma-international.org/ecma-262/6.0/#sec-constructor-properties-of-the-global-object)
* ES6 style classes
* ES6 extended classes (including native subclasses)
* NaN, Infinity, Null, Undefined
```
$ npm install --save arc-is
js
var is = require('arc-is');
is(someUnknownVariable [,returnObjectType]);
`Params
*
someUnknownVariable is the variable you want to typecheck.
* returnObjectType is optional and tells the function if you want it to return a complex type (non native) if available. If false, is() will always return a lowercase string, otherwise it will return a case sensitive string.
Examples
`js
var simpleObj = {};
is(simpleObj); //Returns 'object'
is(simpleObj,true); //Returns 'Object'var es6global = new Map;
is(es6global); //Returns 'map'
is(es6global,true); //Returns 'Map'
class MyClass{ toString(){ return '[object '+this.constructor.name+']'; } }
is(new MyClass); //Returns 'object'
is(new MyClass,true); //Returns 'MyClass';
class MyArray extends Array{ return '[object '+this.constructor.name+']'; } }
is(new MyArray); //Returns 'array'
is(new MyArray,true); //Returns 'MyArray'
``