Comparing version 0.1.2 to 0.1.3
70
is.js
@@ -15,7 +15,7 @@ | ||
, isFinite = isFinite | ||
, NON_HOST_TYPES = { | ||
, NON_HOST_TYPES = { | ||
'boolean': 1 | ||
, 'number': 1 | ||
, 'number': 1 | ||
, 'string': 1 | ||
, 'undefined': 1 | ||
, 'undefined': 1 | ||
} | ||
@@ -29,8 +29,8 @@ ; | ||
*/ | ||
is.version = 0.1.2; | ||
is.version = '0.1.3'; | ||
/** | ||
* Test if 'value' is a type of 'type'. | ||
* | ||
* | ||
* @param value value to test | ||
@@ -42,3 +42,4 @@ * @param {String} type type | ||
is.a = function (value, type) { | ||
is.a = | ||
is.type = function (value, type) { | ||
return typeof value === type; | ||
@@ -49,3 +50,3 @@ }; | ||
* Test if 'value' is an arguments object. | ||
* | ||
* | ||
* @param value value to test | ||
@@ -62,3 +63,3 @@ * @return {Boolean} true if 'value' is an arguments object, false otherwise | ||
* Test if 'value' is an array. | ||
* | ||
* | ||
* @param value value to test | ||
@@ -70,3 +71,3 @@ * @return {Boolean} true if 'value' is an array, false otherwise | ||
is.array = function (value) { | ||
return '[object Array]' === toString.call(value); | ||
return '[object Array]' === toString.call(value); | ||
}; | ||
@@ -76,3 +77,3 @@ | ||
* Test if 'value' is an empty array(like) object. | ||
* | ||
* | ||
* @param {Array|Arguments} value value to test | ||
@@ -83,2 +84,3 @@ * @return {Boolean} true if 'value' is an empty array(like), false otherwise | ||
is.arguments.empty = | ||
is.array.empty = function (value) { | ||
@@ -90,3 +92,3 @@ return value.length === 0; | ||
* Test if 'value' is an arraylike object. | ||
* | ||
* | ||
* @param value value to test | ||
@@ -98,4 +100,4 @@ * @return {Boolean} true if 'value' is an arguments object, false otherwise | ||
is.arraylike = function (value) { | ||
return value !== undefined | ||
&& owns.call(value, 'length') | ||
return value !== undefined | ||
&& owns.call(value, 'length') | ||
&& isFinite(value.length); | ||
@@ -113,3 +115,3 @@ }; | ||
is.boolean = function (value) { | ||
return '[object Boolean]' === toString.call(value); | ||
return '[object Boolean]' === toString.call(value); | ||
}; | ||
@@ -161,6 +163,6 @@ | ||
*/ | ||
is.divisibleBy = function (value, n) { | ||
return '[object Number]' === toString.call(value) | ||
&& n !== 0 | ||
&& n !== 0 | ||
&& value % n === 0; | ||
@@ -177,5 +179,5 @@ }; | ||
is.element = function (value) { | ||
is.element = function (value) { | ||
return value !== undefined | ||
&& owns.call(value, nodeType) | ||
&& owns.call(value, nodeType) | ||
&& value.nodeType === 1; | ||
@@ -197,3 +199,3 @@ }; | ||
if ('[object Array]' === type || '[object Arguments]' === type) { | ||
if ('[object Array]' === type || '[object Arguments]' === type) { | ||
return value.length === 0; | ||
@@ -206,3 +208,3 @@ } | ||
} | ||
if ('[object String]' === type) { | ||
@@ -235,3 +237,3 @@ return value === ''; | ||
is.equal = function (value, other) { | ||
is.equal = function (value, other) { | ||
var undefined | ||
@@ -331,6 +333,6 @@ , type = toString.call(value) | ||
* Test if 'value' is greater than or equal to 'other'. | ||
* | ||
* | ||
* @param {Number} value value to test | ||
* @param {Number} other value to compare with | ||
* @return {Boolean} | ||
* @return {Boolean} | ||
* @api public | ||
@@ -345,6 +347,6 @@ */ | ||
* Test if 'value' is greater than 'other'. | ||
* | ||
* | ||
* @param {Number} value value to test | ||
* @param {Number} other value to compare with | ||
* @return {Boolean} | ||
* @return {Boolean} | ||
* @api public | ||
@@ -359,3 +361,3 @@ */ | ||
* Test if 'value' is an instance of 'constructor'. | ||
* | ||
* | ||
* @param value value to test | ||
@@ -396,3 +398,3 @@ * @return {Boolean} true if 'value' is an instance of 'constructor' | ||
* Test if 'value' is less than or equal to 'other'. | ||
* | ||
* | ||
* @param {Number} value value to test | ||
@@ -410,3 +412,3 @@ * @param {Number} other value to compare with | ||
* Test if 'value' is less than 'other'. | ||
* | ||
* | ||
* @param {Number} value value to test | ||
@@ -424,3 +426,3 @@ * @param {Number} other value to compare with | ||
* Test if 'value' is greater than 'others' values. | ||
* | ||
* | ||
* @param {Number} value value to test | ||
@@ -434,3 +436,3 @@ * @param {Array} others values to compare with | ||
var len = others.length; | ||
while (--len) { | ||
@@ -447,3 +449,3 @@ if (value < others[len]) { | ||
* Test if 'value' is less than 'others' values. | ||
* | ||
* | ||
* @param {Number} value value to test | ||
@@ -457,3 +459,3 @@ * @param {Array} others values to compare with | ||
var len = values.length; | ||
while (--len) { | ||
@@ -464,3 +466,3 @@ if (value > others[len]) { | ||
} | ||
return true; | ||
@@ -467,0 +469,0 @@ }; |
@@ -22,3 +22,3 @@ { | ||
"main": "is.js", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"devDependencies": {}, | ||
@@ -25,0 +25,0 @@ "engines": { |
114
README.md
@@ -5,45 +5,85 @@ # is | ||
To be or not to be? This is the library! | ||
## API | ||
is value ... ? | ||
### general | ||
- a (value, type) | ||
- arguments (value) | ||
- array (value) | ||
- array.empty (value) | ||
- arraylike (value) | ||
- boolean (value) | ||
- date (value) | ||
- decimal (value) | ||
- defined (value) | ||
- divisibleBy (value, n) | ||
- element (value) | ||
- empty (value) | ||
- error (value) | ||
- equal (value, other) | ||
- even (value) | ||
- false (value) | ||
- is.a (value, type) or is.type (value, type) | ||
- is.defined (value) | ||
- is.empty (value) | ||
- is.equal (value, other) | ||
- is.hosted (value, host) | ||
- is.instanceof (value, constructor) | ||
- is.null (value) | ||
- is.undefined (value) | ||
### arguments | ||
- is.arguments (value) | ||
- is.arguments.empty (value) | ||
### array | ||
- is.array (value) | ||
- is.array.empty (value) | ||
- is.arraylike (value) | ||
### boolean | ||
- is.boolean (value) | ||
- is.false (value) | ||
- is.true (value) | ||
### date | ||
- is.date (value) | ||
### element | ||
- is.element (value) | ||
### error | ||
- is.error (value) | ||
### function | ||
- function (value) | ||
- hosted (value, host) | ||
- ge (value, other) | ||
- gt (value, other) | ||
- instanceof (value, constructor) | ||
- int (value) | ||
- nan (value) | ||
- le (value, other) | ||
- lt (value, other) | ||
- maximum (value, others) | ||
- minimum (value, others) | ||
- null (value) | ||
- number (value) | ||
- odd (value) | ||
- object (value) | ||
- regexp (value) | ||
- string (value) | ||
- true (value) | ||
- undefined (value) | ||
- within (value, start, finish) | ||
## License | ||
### number | ||
- is.number (value) | ||
- is.decimal (value) | ||
- is.divisibleBy (value, n) | ||
- is.int (value) | ||
- is.maximum (value, others) | ||
- is.minimum (value, others) | ||
- is.nan (value) | ||
- is.even (value) | ||
- is.odd (value) | ||
- is.ge (value, other) | ||
- is.gt (value, other) | ||
- is.le (value, other) | ||
- is.lt (value, other) | ||
- is.within (value, start, finish) | ||
### object | ||
- is.object (value) | ||
### regexp | ||
- is.regexp (value) | ||
### string | ||
- is.string (value) | ||
## Installation | ||
$ npm install is | ||
## License | ||
(The MIT License) | ||
@@ -50,0 +90,0 @@ |
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
16161
5
462
109