Comparing version 0.1.3 to 0.1.4
498
is.js
@@ -29,5 +29,9 @@ | ||
is.version = '0.1.3'; | ||
is.version = '0.1.4'; | ||
/** | ||
* Test general. | ||
*/ | ||
/** | ||
* Test if 'value' is a type of 'type'. | ||
@@ -47,89 +51,2 @@ * | ||
/** | ||
* Test if 'value' is an arguments object. | ||
* | ||
* @param value value to test | ||
* @return {Boolean} true if 'value' is an arguments object, false otherwise | ||
* @api public | ||
*/ | ||
is.arguments = function (value) { | ||
return '[object Arguments]' === toString.call(value); | ||
}; | ||
/** | ||
* Test if 'value' is an array. | ||
* | ||
* @param value value to test | ||
* @return {Boolean} true if 'value' is an array, false otherwise | ||
* @api public | ||
*/ | ||
is.array = function (value) { | ||
return '[object Array]' === toString.call(value); | ||
}; | ||
/** | ||
* Test if 'value' is an empty array(like) object. | ||
* | ||
* @param {Array|Arguments} value value to test | ||
* @return {Boolean} true if 'value' is an empty array(like), false otherwise | ||
* @api public | ||
*/ | ||
is.arguments.empty = | ||
is.array.empty = function (value) { | ||
return value.length === 0; | ||
}; | ||
/** | ||
* Test if 'value' is an arraylike object. | ||
* | ||
* @param value value to test | ||
* @return {Boolean} true if 'value' is an arguments object, false otherwise | ||
* @api public | ||
*/ | ||
is.arraylike = function (value) { | ||
return value !== undefined | ||
&& owns.call(value, 'length') | ||
&& isFinite(value.length); | ||
}; | ||
/** | ||
* Test if 'value' is a boolean. | ||
* | ||
* @param value value to test | ||
* @return {Boolean} true if 'value' is a boolean, false otherwise | ||
* @api public | ||
*/ | ||
is.boolean = function (value) { | ||
return '[object Boolean]' === toString.call(value); | ||
}; | ||
/** | ||
* Test if 'value' is a date. | ||
* | ||
* @param value value to test | ||
* @return {Boolean} true if 'value' is a date, false otherwise | ||
* @api public | ||
*/ | ||
is.date = function (value) { | ||
return '[object Date]' === toString.call(value); | ||
}; | ||
/** | ||
* Test if 'value' is a decimal number. | ||
* | ||
* @param value value to test | ||
* @return {Boolean} true if 'value' is a decimal number, false otherwise | ||
* @api public | ||
*/ | ||
is.decimal = function (value) { | ||
return '[object Number]' === toString.call(value) && value % 1 !== 0; | ||
}; | ||
/** | ||
* Test if 'value' is defined. | ||
@@ -147,31 +64,2 @@ * | ||
/** | ||
* Test if 'value' is divisible by 'n'. | ||
* | ||
* @param {Number} value value to test | ||
* @param {Number} n dividend | ||
* @return {Boolean} true if 'value' is divisible by 'n', false otherwise | ||
* @api public | ||
*/ | ||
is.divisibleBy = function (value, n) { | ||
return '[object Number]' === toString.call(value) | ||
&& n !== 0 | ||
&& value % n === 0; | ||
}; | ||
/** | ||
* Test if 'value' is an html element. | ||
* | ||
* @param value value to test | ||
* @return {Boolean} true if 'value' is an html element, false otherwise | ||
* @api public | ||
*/ | ||
is.element = function (value) { | ||
return value !== undefined | ||
&& owns.call(value, nodeType) | ||
&& value.nodeType === 1; | ||
}; | ||
/** | ||
* Test if 'value' is empty. | ||
@@ -206,14 +94,2 @@ * | ||
/** | ||
* Test if 'value' is an error object. | ||
* | ||
* @param value value to test | ||
* @return {Boolean} true if 'value' is an error object, false otherwise | ||
* @api public | ||
*/ | ||
is.error = function (value) { | ||
return '[object Error]' === toString.call(value); | ||
}; | ||
/** | ||
* Test if 'value' is equal to 'other'. | ||
@@ -270,14 +146,127 @@ * | ||
/** | ||
* Test if 'value' is an even number. | ||
* Test if 'value' is hosted by 'host'. | ||
* | ||
* @param {Number} value to test | ||
* @return {Boolean} true if 'value' is an even number, false otherwise | ||
* @param {String} value to test | ||
* @param host host | ||
* @return {Boolean} true if 'value' is hosted by 'host', false otherwise | ||
* @api public | ||
*/ | ||
is.even = function (value) { | ||
return '[object Number]' === toString.call(value) && value % 2 === 0; | ||
is.hosted = function (value, host) { | ||
var type = typeof host[value]; | ||
return type === 'object' ? !!host[value] : !NON_HOST_TYPES[type]; | ||
}; | ||
/** | ||
* Test if 'value' is an instance of 'constructor'. | ||
* | ||
* @param value value to test | ||
* @return {Boolean} true if 'value' is an instance of 'constructor' | ||
* @api public | ||
*/ | ||
is.instanceof = function (value, constructor) { | ||
return value instanceof constructor; | ||
}; | ||
/** | ||
* Test if 'value' is null. | ||
* | ||
* @param value to test | ||
* @return {Boolean} true if 'value' is null, false otherwise | ||
* @api public | ||
*/ | ||
is.null = function (value) { | ||
return value === null; | ||
}; | ||
/** | ||
* Test if 'value' is undefined. | ||
* | ||
* @param value value to test | ||
* @return {Boolean} true if 'value' is undefined, false otherwise | ||
* @api public | ||
*/ | ||
is.undefined = function (value) { | ||
return value === undefined; | ||
}; | ||
/** | ||
* Test arguments. | ||
*/ | ||
/** | ||
* Test if 'value' is an arguments object. | ||
* | ||
* @param value value to test | ||
* @return {Boolean} true if 'value' is an arguments object, false otherwise | ||
* @api public | ||
*/ | ||
is.arguments = function (value) { | ||
return '[object Arguments]' === toString.call(value); | ||
}; | ||
/** | ||
* Test array. | ||
*/ | ||
/** | ||
* Test if 'value' is an array. | ||
* | ||
* @param value value to test | ||
* @return {Boolean} true if 'value' is an array, false otherwise | ||
* @api public | ||
*/ | ||
is.array = function (value) { | ||
return '[object Array]' === toString.call(value); | ||
}; | ||
/** | ||
* Test if 'value' is an empty array(like) object. | ||
* | ||
* @param {Array|Arguments} value value to test | ||
* @return {Boolean} true if 'value' is an empty array(like), false otherwise | ||
* @api public | ||
*/ | ||
is.arguments.empty = | ||
is.array.empty = function (value) { | ||
return value.length === 0; | ||
}; | ||
/** | ||
* Test if 'value' is an arraylike object. | ||
* | ||
* @param value value to test | ||
* @return {Boolean} true if 'value' is an arguments object, false otherwise | ||
* @api public | ||
*/ | ||
is.arraylike = function (value) { | ||
return value !== undefined | ||
&& owns.call(value, 'length') | ||
&& isFinite(value.length); | ||
}; | ||
/** | ||
* Test boolean. | ||
*/ | ||
/** | ||
* Test if 'value' is a boolean. | ||
* | ||
* @param value value to test | ||
* @return {Boolean} true if 'value' is a boolean, false otherwise | ||
* @api public | ||
*/ | ||
is.boolean = function (value) { | ||
return '[object Boolean]' === toString.call(value); | ||
}; | ||
/** | ||
* Test if 'value' is false. | ||
@@ -295,113 +284,132 @@ * | ||
/** | ||
* Test if 'value' is a function. | ||
* Test if 'value' is true. | ||
* | ||
* @param value value to test | ||
* @return {Boolean} true if 'value' is a function, false otherwise | ||
* @param {Boolean} value to test | ||
* @return {Boolean} true if 'value' is true, false otherwise | ||
* @api public | ||
*/ | ||
is.function = function(value) { | ||
return '[object Function]' === toString.call(value); | ||
is.true = function (value) { | ||
return value === true; | ||
}; | ||
/** | ||
* Test if 'value' is hosted by 'host'. | ||
* Test date. | ||
*/ | ||
/** | ||
* Test if 'value' is a date. | ||
* | ||
* @param {String} value to test | ||
* @param host host | ||
* @return {Boolean} true if 'value' is hosted by 'host', false otherwise | ||
* @param value value to test | ||
* @return {Boolean} true if 'value' is a date, false otherwise | ||
* @api public | ||
*/ | ||
is.hosted = function (value, host) { | ||
var type = typeof host[value]; | ||
return type === 'object' ? !!host[value] : !NON_HOST_TYPES[type]; | ||
is.date = function (value) { | ||
return '[object Date]' === toString.call(value); | ||
}; | ||
/** | ||
* Test if 'value' is greater than or equal to 'other'. | ||
* Test element. | ||
*/ | ||
/** | ||
* Test if 'value' is an html element. | ||
* | ||
* @param {Number} value value to test | ||
* @param {Number} other value to compare with | ||
* @return {Boolean} | ||
* @param value value to test | ||
* @return {Boolean} true if 'value' is an html element, false otherwise | ||
* @api public | ||
*/ | ||
is.ge = function (value, other) { | ||
return value >= other; | ||
is.element = function (value) { | ||
return value !== undefined | ||
&& owns.call(value, nodeType) | ||
&& value.nodeType === 1; | ||
}; | ||
/** | ||
* Test if 'value' is greater than 'other'. | ||
* Test error. | ||
*/ | ||
/** | ||
* Test if 'value' is an error object. | ||
* | ||
* @param {Number} value value to test | ||
* @param {Number} other value to compare with | ||
* @return {Boolean} | ||
* @param value value to test | ||
* @return {Boolean} true if 'value' is an error object, false otherwise | ||
* @api public | ||
*/ | ||
is.gt = function (value, other) { | ||
return value > other; | ||
is.error = function (value) { | ||
return '[object Error]' === toString.call(value); | ||
}; | ||
/** | ||
* Test if 'value' is an instance of 'constructor'. | ||
* Test function. | ||
*/ | ||
/** | ||
* Test if 'value' is a function. | ||
* | ||
* @param value value to test | ||
* @return {Boolean} true if 'value' is an instance of 'constructor' | ||
* @return {Boolean} true if 'value' is a function, false otherwise | ||
* @api public | ||
*/ | ||
is.instanceof = function (value, constructor) { | ||
return value instanceof constructor; | ||
is.function = function(value) { | ||
return '[object Function]' === toString.call(value); | ||
}; | ||
/** | ||
* Test if 'value' is an integer. | ||
* Test number. | ||
*/ | ||
/** | ||
* Test if 'value' is a number. | ||
* | ||
* @param value to test | ||
* @return {Boolean} true if 'value' is an integer, false otherwise | ||
* @return {Boolean} true if 'value' is a number, false otherwise | ||
* @api public | ||
*/ | ||
is.int = function (value) { | ||
return '[object Number]' === toString.call(value) && value % 1 === 0; | ||
is.number = function (value) { | ||
return '[object Number]' === toString.call(value); | ||
}; | ||
/** | ||
* Test if 'value' is not a number. | ||
* Test if 'value' is a decimal number. | ||
* | ||
* @param value to test | ||
* @return {Boolean} true if 'value' is not a number, false otherwise | ||
* @param value value to test | ||
* @return {Boolean} true if 'value' is a decimal number, false otherwise | ||
* @api public | ||
*/ | ||
is.nan = function (value) { | ||
return value === null || value !== value; | ||
is.decimal = function (value) { | ||
return '[object Number]' === toString.call(value) && value % 1 !== 0; | ||
}; | ||
/** | ||
* Test if 'value' is less than or equal to 'other'. | ||
* Test if 'value' is divisible by 'n'. | ||
* | ||
* @param {Number} value value to test | ||
* @param {Number} other value to compare with | ||
* @return {Boolean} if 'value' is less than or equal to 'other' | ||
* @param {Number} n dividend | ||
* @return {Boolean} true if 'value' is divisible by 'n', false otherwise | ||
* @api public | ||
*/ | ||
is.le = function (value, other) { | ||
return value <= other; | ||
is.divisibleBy = function (value, n) { | ||
return '[object Number]' === toString.call(value) | ||
&& n !== 0 | ||
&& value % n === 0; | ||
}; | ||
/** | ||
* Test if 'value' is less than 'other'. | ||
* Test if 'value' is an integer. | ||
* | ||
* @param {Number} value value to test | ||
* @param {Number} other value to compare with | ||
* @return {Boolean} if 'value' is less than 'other' | ||
* @param value to test | ||
* @return {Boolean} true if 'value' is an integer, false otherwise | ||
* @api public | ||
*/ | ||
is.lt = function (value, other) { | ||
return value < other; | ||
is.int = function (value) { | ||
return '[object Number]' === toString.call(value) && value % 1 === 0; | ||
}; | ||
@@ -452,23 +460,23 @@ | ||
/** | ||
* Test if 'value' is null. | ||
* Test if 'value' is not a number. | ||
* | ||
* @param value to test | ||
* @return {Boolean} true if 'value' is null, false otherwise | ||
* @return {Boolean} true if 'value' is not a number, false otherwise | ||
* @api public | ||
*/ | ||
is.null = function (value) { | ||
return value === null; | ||
is.nan = function (value) { | ||
return value === null || value !== value; | ||
}; | ||
/** | ||
* Test if 'value' is a number. | ||
* Test if 'value' is an even number. | ||
* | ||
* @param value to test | ||
* @return {Boolean} true if 'value' is a number, false otherwise | ||
* @param {Number} value to test | ||
* @return {Boolean} true if 'value' is an even number, false otherwise | ||
* @api public | ||
*/ | ||
is.number = function (value) { | ||
return '[object Number]' === toString.call(value); | ||
is.even = function (value) { | ||
return '[object Number]' === toString.call(value) && value % 2 === 0; | ||
}; | ||
@@ -489,59 +497,51 @@ | ||
/** | ||
* Test if 'value' is an object. | ||
* Test if 'value' is greater than or equal to 'other'. | ||
* | ||
* @param value to test | ||
* @return {Boolean} true if 'value' is an object, false otherwise | ||
* @param {Number} value value to test | ||
* @param {Number} other value to compare with | ||
* @return {Boolean} | ||
* @api public | ||
*/ | ||
is.object = function (value) { | ||
return '[object Object]' === toString.call(value); | ||
} | ||
is.ge = function (value, other) { | ||
return value >= other; | ||
}; | ||
/** | ||
* Test if 'value' is a regular expression. | ||
* Test if 'value' is greater than 'other'. | ||
* | ||
* @param value to test | ||
* @return {Boolean} true if 'value' is a regexp, false otherwise | ||
* @param {Number} value value to test | ||
* @param {Number} other value to compare with | ||
* @return {Boolean} | ||
* @api public | ||
*/ | ||
is.regexp = function (value) { | ||
return '[object RegExp]' === toString.call(value); | ||
is.gt = function (value, other) { | ||
return value > other; | ||
}; | ||
/** | ||
* Test if 'value' is a string. | ||
* Test if 'value' is less than or equal to 'other'. | ||
* | ||
* @param value to test | ||
* @return {Boolean} true if 'value' is a string, false otherwise | ||
* @param {Number} value value to test | ||
* @param {Number} other value to compare with | ||
* @return {Boolean} if 'value' is less than or equal to 'other' | ||
* @api public | ||
*/ | ||
is.string = function (value) { | ||
return '[object String]' === toString.call(value); | ||
} | ||
/** | ||
* Test if 'value' is true. | ||
* | ||
* @param {Boolean} value to test | ||
* @return {Boolean} true if 'value' is true, false otherwise | ||
* @api public | ||
*/ | ||
is.true = function (value) { | ||
return value === true; | ||
is.le = function (value, other) { | ||
return value <= other; | ||
}; | ||
/** | ||
* Test if 'value' is undefined. | ||
* Test if 'value' is less than 'other'. | ||
* | ||
* @param value value to test | ||
* @return {Boolean} true if 'value' is undefined, false otherwise | ||
* @param {Number} value value to test | ||
* @param {Number} other value to compare with | ||
* @return {Boolean} if 'value' is less than 'other' | ||
* @api public | ||
*/ | ||
is.undefined = function (value) { | ||
return value === undefined; | ||
is.lt = function (value, other) { | ||
return value < other; | ||
}; | ||
@@ -560,4 +560,52 @@ | ||
return value >= start && value <= finish; | ||
} | ||
}; | ||
/** | ||
* Test object. | ||
*/ | ||
/** | ||
* Test if 'value' is an object. | ||
* | ||
* @param value to test | ||
* @return {Boolean} true if 'value' is an object, false otherwise | ||
* @api public | ||
*/ | ||
is.object = function (value) { | ||
return '[object Object]' === toString.call(value); | ||
}; | ||
/** | ||
* Test regexp. | ||
*/ | ||
/** | ||
* Test if 'value' is a regular expression. | ||
* | ||
* @param value to test | ||
* @return {Boolean} true if 'value' is a regexp, false otherwise | ||
* @api public | ||
*/ | ||
is.regexp = function (value) { | ||
return '[object RegExp]' === toString.call(value); | ||
}; | ||
/** | ||
* Test string. | ||
*/ | ||
/** | ||
* Test if 'value' is a string. | ||
* | ||
* @param value to test | ||
* @return {Boolean} true if 'value' is a string, false otherwise | ||
* @api public | ||
*/ | ||
is.string = function (value) { | ||
return '[object String]' === toString.call(value); | ||
}; | ||
}(this)); |
@@ -22,3 +22,3 @@ { | ||
"main": "is.js", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"devDependencies": {}, | ||
@@ -25,0 +25,0 @@ "engines": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16540
498