arasatasaygin /is.js

Micro check library

★ 9,056⑂ 611👁 222⑃ 168● 161▤ 0
JavaScriptMITCreated 2015-01-01is.js.org
+0
Daily
9,056
stars
611
forks
222
watchers
168
prs
161
issues
0
releases

README

is.js
=====



 This is a general-purpose check library.
- No dependencies
- AMD, Node & browser ready

 Usage:

Node.js:

npm install is_js


Bower:

bower install is_js


Build:

npm run build


Test:

npm test


 Contributing:
Thanks for considering to contribute. Check here

 Contributors:
Many thanks to our contributors: https://github.com/arasatasaygin/is.js/graphs/contributors

Type checks
===========

is.arguments(value:any)
-----------------------
 Checks if the given value type is arguments.
interfaces: not, all, any

javascript
var getArguments = function() {
    return arguments;
};
var arguments = getArguments();

is.arguments(arguments);
= true

is.not.arguments({foo: 'bar'});
= true

is.all.arguments(arguments, 'bar');
= false

is.any.arguments(['foo'], arguments);
= true

// 'all' and 'any' interfaces can also take array parameter
is.all.arguments([arguments, 'foo', 'bar']);
= false


is.array(value:any)
-------------------
 Checks if the given value type is array.
interfaces: not, all, any

javascript
is.array(['foo', 'bar', 'baz']);
= true

is.not.array({foo: 'bar'});
= true

is.all.array(['foo'], 'bar');
= false

is.any.array(['foo'], 'bar');
= true

// 'all' and 'any' interfaces can also take array parameter
is.all.array([[1, 2], 'foo', 'bar']);
= false


is.boolean(value:any)
---------------------
 Checks if the given value type is boolean.
interfaces: not, all, any

javascript
is.boolean(true);
= true

is.not.boolean({foo: 'bar'});
= true

is.all.boolean(true, 'bar');
= false

is.any.boolean(true, 'bar');
= true

// 'all' and 'any' interfaces can also take array parameter
is.all.boolean([true, 'foo', 'bar']);
= false


is.date(value:any)
------------------
 Checks if the given value type is date.
interfaces: not, all, any

javascript
is.date(new Date());
= true

is.not.date({foo: 'bar'});
= true

is.all.date(new Date(), 'bar');
= false

is.any.date(new Date(), 'bar');
= true

// 'all' and 'any' interfaces can also take array parameter
is.all.date([new Date(), 'foo', 'bar']);
= false


is.domNode(value:any)
-----------------------------
 Checks if the given object is a dom node.
interfaces: not, all, any

javascript
var obj = document.createElement('div');
is.domNode(obj);
= true

is.domNode({nope: 'nope'});
= false

is.not.domNode({});
= true

is.all.domNode(obj, obj);
= true

is.any.domNode(obj, {nope: 'nope'});
= true

// 'all' and 'any' interfaces can also take array parameter
is.all.domNode([obj, {nope: 'nope'}]);
= false


is.error(value:any)
-------------------
 Checks if the given value type is error.
interfaces: not, all, any

javascript
is.error(new Error());
= true

is.not.error({foo: 'bar'});
= true

is.all.error(new Error(), 'bar');
= false

is.any.error(new Error(), 'bar');
= true

// 'all' and 'any' interfaces can also take array parameter
is.all.error([new Error(), 'foo', 'bar']);
= false


is.function(value:any)
----------------------
 Checks if the given value type is function.
interfaces: not, all, any

jav

Top issues

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON