is-extended
is-extended
is a Javascript library that can be used standalone or incorporated into extended
var is = ;
Or
var myextended = ;
Installation
npm install is-extended
Or download the source (minified)
Usage
is-extended
includes the following type coercion methods.
isFunction
: Test if something is a functionisObject
: Test if something is an object.isEmpty
: Test if something is empty.isHash
: Test if something is a hash.
is; //trueis; //false is; //trueis; //true
isNumber
: Test if something is a number.isString
: Test if something is a string.isDate
: Test if something is aDate
.isArray
: Test if something is anObject
isBoolean
: Test if something is a boolean value.isUndefined
: Test if something is strictly equal toundefined
.isDefined
: Test if something is strictly not equal toundefined
.isUndefinedOrNull
: Test if something is strictly equal tonull
orundefined
.isNull
: Test if something is strictly equal tonull
.isArguments
: Test if something is anObject
instanceOf
: Test if something is anObject
isRegExp
: Test if something is aRegExp
isTrue
: Test if something is strictly equal totrue
isFalse
: Test if something is strictly equal tofalse
isNotNull
: Test if something is strictly not equal tonull
.
deepEqual
Tests if two object are deep equal.
is; //true; //true is; //false; //true
isEq
Test if two objects are ==
isNeq
Test if two objects are !=
isSeq
Test if two objects are ===
isSneq
Test if two objects are !==
isIn
Test if an object is in a array.
is; //true ; //true
isNotIn
Test if something is not in an array.
is; //true ; //true
isLt
Check if a value is <
a given value.
is; //true; //true
isLte
Check if a value is <=
a given value.
is; //true; //true
isGt
Check if a value is >
a given value.
is; //true; //true
isGte
Check if a value is >=
a given value.
is; //true; //true
isLike
Check if a value is like a given regexp.
is; //trueis; //true; //trueis; //true
isNotLike
Check if a value is not like a given regexp.
is; //true; //true
contains
Checks if an array contains a given value.
is; //true; //true
notContains
Checks if an array does not contain a given value.
is; //true; //true
containsAt
Checks if an array contains a given value at the specified index
is; //true; //true
notContainsAt
Checks if an array does not contain a given value at the specified index
is; //true; //true
has
Checks if a value has the specified property.
is; //trueis; //true; //true; //true
notHas
Checks if an array does not contain a given value.
is; //trueis; //true; //true; //true
isLength
Checks if a value has the specified length;
is; //trueis; //trueis; //true ; //true; //true; //true
isNotLength
Checks if an value does not have the specified length.
is; //falseis; //falseis; //false ; //false; //false; //false
Creating a custom tester.
To create a custom type tester you can use the tester
method.
var tester = is;; //true; //true; //true; //true; //true; //true ; //false; //false; //false; //false; //false
switcher
The is-exteded
switcher
method allows you to create a structure that executes certain code when a value passes a test.
var mySwitcher = is ; for var i = -1; i < 12; i++ console;
Outputs the following
-1 is lt 0
0 is gte 0 lte 5
1 is gte 0 lte 5
2 is gte 0 lte 5
3 is gte 0 lte 5
4 is gte 0 lte 5
5 is gte 0 lte 5
6 is gt 5 lte 10
7 is gt 5 lte 10
8 is gt 5 lte 10
9 is gt 5 lte 10
10 is gt 5 lte 10
11 is gt 10