MCPcopy Index your code
hub / github.com/arasatasaygin/is.js

github.com/arasatasaygin/is.js @v0.9.0

repository ↗ · DeepWiki ↗ · release v0.9.0 ↗ · + Follow
16 symbols 36 edges 5 files 0 documented · 0%
README

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

is.char(value:any)

Checks if the given value type is char.

interfaces: not, all, any

is.char('f');
=> true

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

is.all.char('f', 1);
=> false

is.any.char('f', 2);
=> true

// 'all' and 'any' interfaces can also take array parameter
is.all.char(['f', 'o', 'o']);
=> true

is.undefined(value:any)

Checks if the given value type is undefined.

interfaces: not, all, any

is.undefined(undefined);
=> true

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

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

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

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

is.sameType(value:any, other:any)

Checks if the given value types are same type.

interface: not

is.sameType(42, 7);
=> true

is.sameType(42, '7');
=> false

is.not.sameType(42, 7);
=> false

is.windowObject(value:any)

Checks if the given object is window object.

interfaces: not, all, any

is.windowObject(window);
=> true

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

is.not.windowObject({});
=> true

is.all.windowObject(window, {nope: 'nope'});
=> false

is.any.windowObject(window, {nope: 'nope'});
=> true

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

Presence checks

is.empty(value:array|object|string)

Checks if the given value is empty.

interfaces: not, all, any

is.empty({});
=> true

is.empty([]);
=> true

is.empty('');
=> true

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

is.all.empty('', {}, ['foo']);
=> false

is.any.empty([], 42);
=> true

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

is.existy(value:any)

Checks if the given value is existy. (not null or undefined)

interfaces: not, all, any

is.existy({});
=> true

is.existy(null);
=> false

is.not.existy(undefined);
=> true

is.all.existy(null, ['foo']);
=> false

is.any.existy(undefined, 42);
=> true

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

is.truthy(value:any)

Checks if the given value is truthy. (existy and not false)

interfaces: not, all, any

is.truthy(true);
=> true

is.truthy(null);
=> false

is.not.truthy(false);
=> true

is.all.truthy(null, true);
=> false

is.any.truthy(undefined, true);
=> true

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

is.falsy(value:any)

Checks if the given value is falsy.

interfaces: not, all, any

is.falsy(false);
=> true

is.falsy(null);
=> true

is.not.falsy(true);
=> true

is.all.falsy(null, false);
=> true

is.any.falsy(undefined, true);
=> true

// 'all' and 'any' interfaces can also take array parameter
is.all.falsy([false, true, undefined]);
=> false

is.space(value:any)

Checks if the given value is space.

interfaces: not, all, any

is.space(' ');
=> true

is.space('foo');
=> false

is.not.space(true);
=> true

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

is.any.space(' ', true);
=> true

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

RegExp checks

is.url(value:any)

Checks if the given value matches url regexp.

interfaces: not, all, any

is.url('http://www.test.com');
=> true

is.url('foo');
=> false

is.not.url(true);
=> true

is.all.url('http://www.test.com', 'foo');
=> false

is.any.url('http://www.test.com', true);
=> true

// 'all' and 'any' interfaces can also take array parameter
is.all.url(['http://www.test.com', 'foo', undefined]);
=> false

is.email(value:any)

Checks if the given value matches email regexp.

interfaces: not, all, any

is.email('test@test.com');
=> true

is.email('foo');
=> false

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

is.all.email('test@test.com', 'foo');
=> false

is.any.email('test@test.com', 'foo');
=> true

// 'all' and 'any' interfaces can also take array parameter
is.all.email(['test@test.com', 'foo', undefined]);
=> false

is.creditCard(value:any)

Checks if the given value matches credit card regexp.

interfaces: not, all, any

is.creditCard(378282246310005);
=> true

is.creditCard(123);
=> false

is.not.creditCard(123);
=> true

is.all.creditCard(378282246310005, 123);
=> false

is.any.creditCard(378282246310005, 123);
=> true

// 'all' and 'any' interfaces can also take array parameter
is.all.creditCard([378282246310005, 123, undefined]);
=> false

is.alphaNumeric(value:any)

Checks if the given value matches alpha numeric regexp.

interfaces: not, all, any

is.alphaNumeric('alphaNu3er1k');
=> true

is.alphaNumeric('*?');
=> false

is.not.alphaNumeric('*?');
=> true

is.all.alphaNumeric('alphaNu3er1k', '*?');
=> false

is.any.alphaNumeric('alphaNu3er1k', '*?');
=> true

// 'all' and 'any' interfaces can also take array parameter
is.all.alphaNumeric(['alphaNu3er1k', '*?']);
=> false

is.timeString(value:any)

Checks if the given value matches time string regexp.

interfaces: not, all, any

is.timeString('13:45:30');
=> true

is.timeString('90:90:90');
=> false

is.not.timeString('90:90:90');
=> true

is.all.timeString('13:45:30', '90:90:90');
=> false

is.any.timeString('13:45:30', '90:90:90');
=> true

// 'all' and 'any' interfaces can also take array parameter
is.all.timeString(['13:45:30', '90:90:90']);
=> false

is.dateString(value:any)

Checks if the given value matches date string regexp.

interfaces: not, all, any

is.dateString('11/11/2011');
=> true

is.dateString('10-21-2012');
=> true

is.dateString('90/11/2011');
=> false

is.not.dateString('90/11/2011');
=> true

is.all.dateString('11/11/2011', '90/11/2011');
=> false

is.any.dateString('11-11-2011', '90/11/2011');
=> true

// 'all' and 'any' interfaces can also take array parameter
is.all.dateString(['11/11/2011', '90/11/2011']);
=> false

is.usZipCode(value:any)

Checks if the given value matches US zip code regexp.

interfaces: not, all, any

is.usZipCode('02201-1020');
=> true

is.usZipCode('123');
=> false

is.not.usZipCode('123');
=> true

is.all.usZipCode('02201-1020', '123');
=> false

is.any.usZipCode('02201-1020', '123');
=> true

// 'all' and 'any' interfaces can also take array parameter
is.all.usZipCode(['02201-1020', '123']);
=> false

is.caPostalCode(value:any)

Checks if the given value matches Canada postal code regexp.

interfaces: not, all, any

is.caPostalCode('L8V3Y1');
=> true

is.caPostalCode('L8V 3Y1');
=> true

is.caPostalCode('123');
=> false

is.not.caPostalCode('123');
=> true

is.all.caPostalCode('L8V3Y1', '123');
=> false

is.any.caPostalCode('L8V3Y1', '123');
=> true

// 'all' and 'any' interfaces can also take array parameter
is.all.caPostalCode(['L8V3Y1', '123']);
=> false

is.ukPostCode(value:any)

Checks if the given value matches UK post code regexp.

interfaces: not, all, any

```javascript is.ukPostCode('B184BJ'); => true

is.ukPostCode('123'); => false

is.not.ukPostCode('123'); => true

is.all.ukPostCode('B184BJ', '123'); => false

is.any.ukPostCode('B184BJ', '123'); => true

// 'all' and 'any' interfaces can also take array p

Core symbols most depended-on inside this repo

checkApi
called by 84
test/test.js
compareVersion
called by 10
is.js
not
called by 4
is.js
getParams
called by 2
is.js
all
called by 1
is.js
any
called by 1
is.js
regexpCheck
called by 1
is.js
setInterfaces
called by 1
is.js

Shape

Function 16

Languages

TypeScript100%

Modules by API surface

is.min.js7 symbols
is.js7 symbols
test/test.js2 symbols

Dependencies from manifests, versioned

chai3.4.0 · 1×
eslint2.13.1 · 1×
lodash4.15.0 · 1×
mocha2.2.1 · 1×
mocha-phantomjs4.1.0 · 1×
pre-commit1.1.3 · 1×
uglify-js2.7.3 · 1×

For agents

$ claude mcp add is.js \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact