• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

arasatasaygin/is.js: Micro check library

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

arasatasaygin/is.js

开源软件地址(OpenSource Url):

https://github.com/arasatasaygin/is.js

开源编程语言(OpenSource Language):

JavaScript 99.3%

开源软件介绍(OpenSource Introduction):

is.js

JS.ORG

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

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

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

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

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

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

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

is.function(toString);
=> true

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

is.all.function(toString, 'bar');
=> false

is.any.function(toString, 'bar');
=> true

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

is.nan(value:any)

Checks if the given value type is NaN.

interfaces: not, all, any

is.nan(NaN);
=> true

is.not.nan(42);
=> true

is.all.nan(NaN, 1);
=> false

is.any.nan(NaN, 2);
=> true

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

is.null(value:any)

Checks if the given value type is null.

interfaces: not, all, any

is.null(null);
=> true

is.not.null(42);
=> true

is.all.null(null, 1);
=> false

is.any.null(null, 2);
=> true

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

is.number(value:any)

Checks if the given value type is number.

interfaces: not, all, any

is.number(42);
=> true

is.number(NaN);
=> false

is.not.number('42');
=> true

is.all.number('foo', 1);
=> false

is.any.number({}, 2);
=> true

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

is.object(value:any)

Checks if the given value type is object.

interfaces: not, all, any

is.object({foo: 'bar'});
=> true

// functions are also returning as true
is.object(toString);
=> true

is.not.object('foo');
=> true

is.all.object({}, 1);
=> false

is.any.object({}, 2);
=> true

// 'all' and 'any' interfaces can also take array parameter
is.all.object([{}, new Object()]);
=> true

is.json(value:any)

Checks if the given value type is pure json object.

interfaces: not, all, any

is.json({foo: 'bar'});
=> true

// functions are returning as false
is.json(toString);
=> false

is.not.json([]);
=> true

is.all.json({}, 1);
=> false

is.any.json({}, 2);
=> true

// 'all' and 'any' interfaces can also take array parameter
is.all.json([{}, {foo: 'bar'}]);
=> true

is.regexp(value:any)

Checks if the given value type is RegExp.

interfaces: not, all, any

is.regexp(/test/);
=> true

is.not.regexp(['foo']);
=> true

is.all.regexp(/test/, 1);
=> false

is.any.regexp(new RegExp('ab+c'), 2);
=> true

// 'all' and 'any' interfaces can also take array parameter
is.all.regexp([{}, /test/]);
=> false

is.string(value:any)

Checks if the given value type is string.

interfaces: not, all, any

is.string('foo');
=> true

is.not.string(['foo']);
=> true

is.all.string('foo', 1);
=> false

is.any.string('foo', 2);
=> true

// 'all' and 'any' interfaces can also take array parameter
is.all.string([{}, 'foo']);
=> false

上一篇:
chriskohlhoff/asio: Asio C++ Library发布时间:2022-08-15
下一篇:
AzureAD/azure-activedirectory-library-for-python: ADAL for Python发布时间:2022-08-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap