+13
-11
@@ -5,3 +5,3 @@ | ||
| * the definitive JavaScript type testing library | ||
| * | ||
| * | ||
| * @copyright 2013 Enrico Marino | ||
@@ -18,6 +18,6 @@ * @license MIT | ||
| var NON_HOST_TYPES = { | ||
| "boolean": 1, | ||
| "number": 1, | ||
| "string": 1, | ||
| "undefined": 1 | ||
| boolean: 1, | ||
| number: 1, | ||
| string: 1, | ||
| undefined: 1 | ||
| }; | ||
@@ -81,3 +81,5 @@ | ||
| if ('[object Object]' === type) { | ||
| for (key in value) if (owns.call(value, key)) return false; | ||
| for (key in value) { | ||
| if (owns.call(value, key)) { return false; } | ||
| } | ||
| return true; | ||
@@ -182,3 +184,3 @@ } | ||
| /** | ||
| * is.null | ||
| * is.nil / is.null | ||
| * Test if `value` is null. | ||
@@ -191,3 +193,3 @@ * | ||
| is['null'] = function (value) { | ||
| is.nil = is['null'] = function (value) { | ||
| return value === null; | ||
@@ -197,3 +199,3 @@ }; | ||
| /** | ||
| * is.undef | ||
| * is.undef / is.undefined | ||
| * Test if `value` is undefined. | ||
@@ -314,3 +316,3 @@ * | ||
| is['false'] = function (value) { | ||
| return is.boolean(value) && (value === false || value.valueOf() === false); | ||
| return is.boolean(value) && Boolean(Number(value)) === false; | ||
| }; | ||
@@ -328,3 +330,3 @@ | ||
| is['true'] = function (value) { | ||
| return is.boolean(value) && (value === true || value.valueOf() === true); | ||
| return is.boolean(value) && Boolean(Number(value)) === true; | ||
| }; | ||
@@ -331,0 +333,0 @@ |
+6
-4
| { | ||
| "name": "is", | ||
| "version": "1.0.0", | ||
| "version": "1.1.0", | ||
| "main": "index.js", | ||
| "scripts": { | ||
| "test": "node test/index.js", | ||
| "test": "npm run lint && node test/index.js", | ||
| "coverage": "covert test/index.js", | ||
| "coverage-quiet": "covert test/index.js --quiet" | ||
| "coverage-quiet": "covert test/index.js --quiet", | ||
| "lint": "jscs *.js */*.js" | ||
| }, | ||
@@ -35,3 +36,4 @@ "author": { | ||
| "foreach": "~2.0.4", | ||
| "covert": "~0.4.0" | ||
| "covert": "~1.0.0", | ||
| "jscs": "~1.5.9" | ||
| }, | ||
@@ -38,0 +40,0 @@ "testling": { |
+66
-75
@@ -1,3 +0,9 @@ | ||
| # is | ||
| # is <sup>[![Version Badge][2]][1]</sup> | ||
| [![Build Status][3]][4] [![dependency status][5]][6] [![dev dependency status][7]][8] | ||
| [![npm badge][11]][1] | ||
| [![browser support][9]][10] | ||
| The definitive JavaScript type testing library | ||
@@ -7,4 +13,2 @@ | ||
| [![browser support][1]][2] | ||
| ## Installation | ||
@@ -14,8 +18,11 @@ | ||
| $ npm install is | ||
| ```shell | ||
| $ npm install is | ||
| ``` | ||
| As a component | ||
| ```shell | ||
| $ component install enricomarino/is | ||
| ``` | ||
| $ component install enricomarino/is | ||
| ## API | ||
@@ -25,38 +32,39 @@ | ||
| - is.a (value, type) or is.type (value, type) | ||
| - is.defined (value) | ||
| - is.empty (value) | ||
| - is.equal (value, other) | ||
| - is.hosted (value, host) | ||
| - is.instance (value, constructor) | ||
| - is.instanceof (value, constructor) - deprecated, because in ES3 browsers, "instanceof" is a reserved word | ||
| - is.null (value) - deprecated, because in ES3 browsers, "null" is a reserved word | ||
| - is.undef (value) | ||
| - is.undefined (value) - deprecated, because in ES3 browsers, "undefined" is a reserved word | ||
| - ``is.a`` (value, type) or ``is.type`` (value, type) | ||
| - ``is.defined`` (value) | ||
| - ``is.empty`` (value) | ||
| - ``is.equal`` (value, other) | ||
| - ``is.hosted`` (value, host) | ||
| - ``is.instance`` (value, constructor) | ||
| - ``is.instanceof`` (value, constructor) - deprecated, because in ES3 browsers, "instanceof" is a reserved word | ||
| - ``is.nil`` (value) | ||
| - ``is.null`` (value) - deprecated, because in ES3 browsers, "null" is a reserved word | ||
| - ``is.undef`` (value) | ||
| - ``is.undefined`` (value) - deprecated, because in ES3 browsers, "undefined" is a reserved word | ||
| ### arguments | ||
| - is.args (value) | ||
| - is.arguments (value) - deprecated, because "arguments" is a reserved word | ||
| - is.args.empty (value) | ||
| - ``is.args`` (value) | ||
| - ``is.arguments`` (value) - deprecated, because "arguments" is a reserved word | ||
| - ``is.args.empty`` (value) | ||
| ### array | ||
| - is.array (value) | ||
| - is.array.empty (value) | ||
| - is.arraylike (value) | ||
| - ``is.array`` (value) | ||
| - ``is.array.empty`` (value) | ||
| - ``is.arraylike`` (value) | ||
| ### boolean | ||
| - is.boolean (value) | ||
| - is.false (value) - deprecated, because in ES3 browsers, "false" is a reserved word | ||
| - is.true (value) - deprecated, because in ES3 browsers, "true" is a reserved word | ||
| - ``is.boolean`` (value) | ||
| - ``is.false`` (value) - deprecated, because in ES3 browsers, "false" is a reserved word | ||
| - ``is.true`` (value) - deprecated, because in ES3 browsers, "true" is a reserved word | ||
| ### date | ||
| - is.date (value) | ||
| - ``is.date`` (value) | ||
| ### element | ||
| - is.element (value) | ||
| - ``is.element`` (value) | ||
@@ -69,34 +77,34 @@ ### error | ||
| - is.fn(value) | ||
| - is.function(value) - deprecated, because in ES3 browsers, "function" is a reserved word | ||
| - ``is.fn`` (value) | ||
| - ``is.function`` (value) - deprecated, because in ES3 browsers, "function" is a reserved word | ||
| ### number | ||
| - is.number (value) | ||
| - is.infinite (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) | ||
| - ``is.number`` (value) | ||
| - ``is.infinite`` (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) | ||
| - ``is.object`` (value) | ||
| ### regexp | ||
| - is.regexp (value) | ||
| - ``is.regexp`` (value) | ||
| ### string | ||
| - is.string (value) | ||
| - ``is.string`` (value) | ||
@@ -108,30 +116,13 @@ | ||
| ## License | ||
| [1]: https://npmjs.org/package/is | ||
| [2]: http://vb.teelaun.ch/enricomarino/is.svg | ||
| [3]: https://travis-ci.org/enricomarino/is.svg | ||
| [4]: https://travis-ci.org/enricomarino/is | ||
| [5]: https://david-dm.org/enricomarino/is.svg | ||
| [6]: https://david-dm.org/enricomarino/is | ||
| [7]: https://david-dm.org/enricomarino/is/dev-status.svg | ||
| [8]: https://david-dm.org/enricomarino/is#info=devDependencies | ||
| [9]: https://ci.testling.com/enricomarino/is.png | ||
| [10]: https://ci.testling.com/enricomarino/is | ||
| [11]: https://nodei.co/npm/is.png?downloads=true&stars=true | ||
| (The MIT License) | ||
| Copyright (c) 2013 Enrico Marino | ||
| Copyright (c) 2014 Enrico Marino and Jordan Harband | ||
| Permission is hereby granted, free of charge, to any person obtaining | ||
| a copy of this software and associated documentation files (the | ||
| 'Software'), to deal in the Software without restriction, including | ||
| without limitation the rights to use, copy, modify, merge, publish, | ||
| distribute, sublicense, and/or sell copies of the Software, and to | ||
| permit persons to whom the Software is furnished to do so, subject to | ||
| the following conditions: | ||
| The above copyright notice and this permission notice shall be | ||
| included in all copies or substantial portions of the Software. | ||
| THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | ||
| EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
| IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
| CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
| TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
| SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| [1]: https://ci.testling.com/enricomarino/is.png | ||
| [2]: https://ci.testling.com/enricomarino/is | ||
+3
-2
@@ -158,4 +158,5 @@ var test = require('tape'); | ||
| test('is.null', function (t) { | ||
| var isNull = is['null']; | ||
| test('is.nil', function (t) { | ||
| var isNull = is.nil; | ||
| t.equal(isNull, is['null'], 'is.nil is the same as is.null'); | ||
| t.ok(isNull(null), 'null is null'); | ||
@@ -162,0 +163,0 @@ t.notOk(isNull(undefined), 'undefined is not null'); |
1120
0.27%44613
-0.46%4
33.33%124
-6.77%