node package manager


Tiny tiny duck typing utility


Tiny tiny Library to check object types. Works in node and your browser.

Use it like this:

first require it:

var is = require('dis');

or in browser:

<script type="text/javascript" src="dis"></script>

You'll find the browser version in /dist;

Then check:





is(<obj>, Object)

all are equally valid, but note that the function call is.<type>(<object>) will do a thorough check whereas is(<object>,<type>) will do a shallow check (simply calling Object.prototype.toString on the object);

You can also do things like:

     is(<obj>) // returns type as a string 
     is(<var1>,<var2>,<var3>,...,Array) // checks that all vars are of type 'array' 

note: I use "is" because it's shorter and more explicative. This is how I had named the plugin originally, but the name was not available on npm, so I had to revert to something else. the original "is" plugin is here. It's sorta similar, but has more functions, and a different API. See if you like it better.

All functions are available separately. If you know you'll only need to check for 'empty', for example, then you can just include var isEmpty = require('dis/lib/isEmpty).

To do this in the browser, you'll need to whip up your own build, through gulp, webpack, or whatever tickles your fancy.

Returns a string that represents the object's type. That string might be any of:

  • arguments
  • array
  • boolean
  • date
  • error
  • function
  • html collection (depending on the browser)
  • null
  • number
  • object
  • regexp
  • string
  • undefined

If called without the type arguments, yields same results as is.type, but has more thorough checks. Whereas is.type simply calls Object.prototype.toString on the object, is.check goes through all the checks available to determine the type. Of course, this is much slower.

If called with the type argument, checks the object against the type provided, where type is:

  • a string ('array', 'string', ...)
  • a native function (Array, String)
  • a named function function NamedFunction(){}
  • true
  • false

If type is not a known type, throws an error.

You can add your own tests by overloading the is.check.tests object.

function CustomObject(){}
is.check.tests.customObj = function(obj){
    return obj instanceof CustomObject;
var obj = new CustomObject();
console.log(is.checkType(obj)) //returns 'customObj' 
console.log(is.checkType(obj,'customObj'))//return `true` 

Tests if obj is of type, where obj is anything, and type is:

  • a string ('array', 'string', ...)
  • a native function (Array, String)
  • a named function function NamedFunction(){}
  • true
  • false

is.test makes use of is.type, so it won't check for custom objects like is.checkType would.

Same as is.test, but will test all provided objects against the type.

Checks that all provided objects are of the same type. If not, returns false. If they are, returns the type as a string. Aliases as is.sameType.

Alias for is.type(obj)

Alias for is.test(obj,type)

Alias for is.testMultiple

Checks if obj is an arguments object. Please be aware than passing the arguments around stops optimization.
Alias: is.args.

Checks if obj is an Array.
Aliases: is.arr

Checks if obj is strictly true or false.
Alias: is.bool

Checks if obj is a date object.

Checks if obj is defined.
Alias: is.def

Checks if obj is an empty array, an object with no properties, false, or an empty string. In essence, checks if the object is 'falsy'.
Aliases: is.false, is.falsy

Checks if obj is of type Error.
Alias: is.err

Checks if obj is a Function. Aliases:,is.fn,is.func

Checks if obj is an HTML nodes collection.
Aliases: is.htmlCollection, is.htmlcollection

Checks if obj is an integer.

Checks if obj is a native function.

Checks if obj is an HTML node.

Checks if obj is strictly null.

Checks if obj is strictly a number.

Checks if obj can be cast to a number. Works on strings etc.

Checks if obj is a plain object, that is, if its prototype is Object.
Alias: is.obj

Checks if obj would be passed by reference. Anything else than string or number returns true.
Alias: is.ref

Checks if obj is of RegExp type.
Aliases: is.regExp, is.regularExpression

Checks if obj is a String.
Aliases: is.str

Checks if obj is truthy. Empty arrays, empty objects and the like return false.
Alias: is.truthy

Checks if obj is undefined.
Alias: is.undef


npm test

continuous testing

npom run dev


npm run build