Comparing version 2.2.0 to 2.3.0
@@ -14,2 +14,3 @@ "use strict"; | ||
exports.isObject = isObject; | ||
exports.isDefined = isDefined; | ||
@@ -44,3 +45,4 @@ /** | ||
/** | ||
Returns true if input `typeof` is `object` and directly decends from `Object` (and not `Array`, `RegExp` etc.) | ||
A plain object is a simple object literal, it is not an instance of a class. Returns true if the input `typeof` is `object` and directly decends from `Object`. | ||
@param {*} - the input to test | ||
@@ -66,6 +68,12 @@ @returns {boolean} | ||
/** | ||
returns true if this object can be treated like an Array. | ||
An array-like value has all the properties of an array, but is not an array instance. Examples in the `arguments` object. Returns true if the input value is an object, not null and has a `length` property with a numeric value. | ||
@param {*} - the input to test | ||
@returns {boolean} | ||
@static | ||
@example | ||
function sum(x, y){ | ||
console.log(t.isArrayLike(arguments)); | ||
// prints `true` | ||
} | ||
*/ | ||
@@ -85,1 +93,11 @@ function isArrayLike(input){ | ||
} | ||
/** | ||
Returns true if the input value is defined | ||
@param {*} - the input to test | ||
@returns {boolean} | ||
@static | ||
*/ | ||
function isDefined(input){ | ||
return typeof input !== "undefined"; | ||
} |
{ | ||
"name": "typical", | ||
"author": "Lloyd Brookes <75pound@gmail.com>", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"description": "For type-checking Javascript values.", | ||
@@ -6,0 +6,0 @@ "repository": "https://github.com/75lb/typical.git", |
@@ -20,2 +20,3 @@ [![view on npm](http://img.shields.io/npm/v/typical.svg)](https://www.npmjs.org/package/typical) | ||
* [.isObject(input)](#module_typical.isObject) ⇒ <code>boolean</code> | ||
* [.isDefined(input)](#module_typical.isDefined) ⇒ <code>boolean</code> | ||
@@ -53,3 +54,3 @@ <a name="module_typical.isNumber"></a> | ||
### t.isPlainObject(input) ⇒ <code>boolean</code> | ||
Returns true if input `typeof` is `object` and directly decends from `Object` (and not `Array`, `RegExp` etc.) | ||
A plain object is a simple object literal, it is not an instance of a class. Returns true if the input `typeof` is `object` and directly decends from `Object`. | ||
@@ -77,3 +78,3 @@ **Kind**: static method of <code>[typical](#module_typical)</code> | ||
### t.isArrayLike(input) ⇒ <code>boolean</code> | ||
returns true if this object can be treated like an Array. | ||
An array-like value has all the properties of an array, but is not an array instance. Examples in the `arguments` object. Returns true if the input value is an object, not null and has a `length` property with a numeric value. | ||
@@ -86,2 +87,9 @@ **Kind**: static method of <code>[typical](#module_typical)</code> | ||
**Example** | ||
```js | ||
function sum(x, y){ | ||
console.log(t.isArrayLike(arguments)); | ||
// prints `true` | ||
} | ||
``` | ||
<a name="module_typical.isObject"></a> | ||
@@ -97,5 +105,15 @@ ### t.isObject(input) ⇒ <code>boolean</code> | ||
<a name="module_typical.isDefined"></a> | ||
### t.isDefined(input) ⇒ <code>boolean</code> | ||
Returns true if the input value is defined | ||
**Kind**: static method of <code>[typical](#module_typical)</code> | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| input | <code>\*</code> | the input to test | | ||
* * * | ||
© 2015 Lloyd Brookes \<75pound@gmail.com\>. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown). |
@@ -26,1 +26,10 @@ var test = require("tape"); | ||
}); | ||
test(".isPlainObject(value)", function(t){ | ||
t.strictEqual(type.isDefined({}), true); | ||
t.strictEqual(type.isDefined({}.one), false); | ||
t.strictEqual(type.isDefined(0), true); | ||
t.strictEqual(type.isDefined(null), true); | ||
t.strictEqual(type.isDefined(undefined), false); | ||
t.end(); | ||
}); |
8336
121
115