+0
日增长
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
javTop issues
#154is.url15 comments · 2015-09-25#324Trying to get in touch regarding a security issue8 comments · 2021-08-27#294Proposal: is.primitive() to test for boolean, number, or string7 comments · 2018-09-06#286Moving to ES6?7 comments · 2018-05-21#322TypeScript support?6 comments · 2021-04-01#320Security Issue: Request for contact5 comments · 2020-11-30#248Using code prettifier for gh-pages5 comments · 2016-10-03#244is.json5 comments · 2016-09-05