Comparing version 5.1.0 to 5.2.0
@@ -8,3 +8,3 @@ (function (global, factory) { | ||
/** | ||
* For type-checking Javascript values. | ||
* Isomorphic, functional type-checking for Javascript. | ||
* @module typical | ||
@@ -14,6 +14,8 @@ * @typicalname t | ||
* const t = require('typical') | ||
* const allDefined = array.every(t.isDefined) | ||
*/ | ||
/** | ||
* Returns true if input is a number | ||
* Returns true if input is a number. It is a more reasonable alternative to `typeof n` which returns `number` for `NaN` and `Infinity`. | ||
* | ||
* @param {*} - the input to test | ||
@@ -75,3 +77,3 @@ * @returns {boolean} | ||
/** | ||
* 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. | ||
* An array-like value has all the properties of an array yet is not an array instance. An example is the `arguments` object. Returns `true`` if the input value is an object, not `null`` and has a `length` property set with a numeric value. | ||
* | ||
@@ -112,2 +114,32 @@ * @param {*} - the input to test | ||
/** | ||
* Returns true if the input value is undefined. | ||
* @param {*} - the input to test | ||
* @returns {boolean} | ||
* @static | ||
*/ | ||
function isUndefined (input) { | ||
return !isDefined(input) | ||
} | ||
/** | ||
* Returns true if the input value is null. | ||
* @param {*} - the input to test | ||
* @returns {boolean} | ||
* @static | ||
*/ | ||
function isNull (input) { | ||
return input === null | ||
} | ||
/** | ||
* Returns true if the input value is both defined and not null. | ||
* @param {*} - the input to test | ||
* @returns {boolean} | ||
* @static | ||
*/ | ||
function isDefinedValue (input) { | ||
return isDefined(input) && !isNull(input) && !Number.isNaN(input) | ||
} | ||
/** | ||
* Returns true if the input value is an ES2015 `class`. | ||
@@ -213,3 +245,3 @@ * @param {*} - the input to test | ||
/** | ||
* Returns true if the input value is a string. The equivalent of `typeof input === 'string'`` for use in funcitonal contexts. | ||
* Returns true if the input value is a string. The equivalent of `typeof input === 'string'` for use in funcitonal contexts. | ||
* @param {*} - the input to test | ||
@@ -224,3 +256,3 @@ * @returns {boolean} | ||
/** | ||
* Returns true if the input value is a function. The equivalent of `typeof input === 'function'`` for use in funcitonal contexts. | ||
* Returns true if the input value is a function. The equivalent of `typeof input === 'function'` for use in funcitonal contexts. | ||
* @param {*} - the input to test | ||
@@ -240,2 +272,5 @@ * @returns {boolean} | ||
isDefined, | ||
isUndefined, | ||
isNull, | ||
isDefinedValue, | ||
isClass, | ||
@@ -253,4 +288,6 @@ isPrimitive, | ||
exports.isDefined = isDefined; | ||
exports.isDefinedValue = isDefinedValue; | ||
exports.isFunction = isFunction; | ||
exports.isIterable = isIterable; | ||
exports.isNull = isNull; | ||
exports.isNumber = isNumber; | ||
@@ -262,2 +299,3 @@ exports.isObject = isObject; | ||
exports.isString = isString; | ||
exports.isUndefined = isUndefined; | ||
@@ -264,0 +302,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
{ | ||
"name": "typical", | ||
"author": "Lloyd Brookes <75pound@gmail.com>", | ||
"version": "5.1.0", | ||
"description": "Functional, isomorphic, load-anywhere type checking for Javascript", | ||
"version": "5.2.0", | ||
"description": "Isomorphic, functional type-checking for Javascript", | ||
"repository": "https://github.com/75lb/typical", | ||
@@ -40,8 +40,8 @@ "license": "MIT", | ||
"scripts": { | ||
"test": "npm run test:js && npm run test:esm", | ||
"test": "npm run dist && npm run test:js && npm run test:esm", | ||
"test:all": "npm run test:js && npm run test:esm && npm run test:web", | ||
"test:js": "rollup test/*.mjs -f cjs -d tmp/test && test-runner tmp/test/test*.js", | ||
"test:js": "rollup test/*.mjs -f cjs -d tmp/test -e assert && test-runner tmp/test/test*.js", | ||
"test:esm": "esm-runner test/*.mjs", | ||
"test:web": "web-runner test/test.mjs", | ||
"test:v8": "rollup test/test.mjs test/test-default.mjs -f cjs -d tmp/test && test-runner tmp/test/test*.js", | ||
"test:v8": "rollup test/test.mjs test/test-default.mjs -f cjs -d tmp/testv8 && test-runner tmp/testv8/test*.js", | ||
"dist": "rollup index.mjs -f umd -n typical -o dist/index.js --exports named", | ||
@@ -52,7 +52,7 @@ "docs": "jsdoc2md -c jsdoc.conf -t README.hbs index.mjs > README.md; echo", | ||
"devDependencies": { | ||
"coveralls": "^3.0.4", | ||
"esm-runner": "^0.1.4", | ||
"jsdoc-to-markdown": "^5.0.0", | ||
"coveralls": "^3.0.7", | ||
"esm-runner": "^0.1.5", | ||
"jsdoc-to-markdown": "^5.0.2", | ||
"nyc": "^14.1.1", | ||
"rollup": "^1.16.2", | ||
"rollup": "^1.25.1", | ||
"test-object-model": "^0.4.4", | ||
@@ -59,0 +59,0 @@ "test-runner": "^0.6.0" |
@@ -11,3 +11,3 @@ [![view on npm](http://img.shields.io/npm/v/typical.svg)](https://www.npmjs.org/package/typical) | ||
## typical | ||
Functional, isomorphic, load-anywhere type checking for Javascript. | ||
Isomorphic, functional type-checking for Javascript. | ||
@@ -17,2 +17,3 @@ **Example** | ||
const t = require('typical') | ||
const allDefined = array.every(t.isDefined) | ||
``` | ||
@@ -26,2 +27,5 @@ | ||
* [.isDefined(input)](#module_typical.isDefined) ⇒ <code>boolean</code> | ||
* [.isUndefined(input)](#module_typical.isUndefined) ⇒ <code>boolean</code> | ||
* [.isNull(input)](#module_typical.isNull) ⇒ <code>boolean</code> | ||
* [.isDefinedValue(input)](#module_typical.isDefinedValue) ⇒ <code>boolean</code> | ||
* [.isClass(input)](#module_typical.isClass) ⇒ <code>boolean</code> | ||
@@ -37,3 +41,3 @@ * [.isPrimitive(input)](#module_typical.isPrimitive) ⇒ <code>boolean</code> | ||
### t.isNumber(n) ⇒ <code>boolean</code> | ||
Returns true if input is a number | ||
Returns true if input is a number. It is a more reasonable alternative to `typeof n` which returns `number` for `NaN` and `Infinity`. | ||
@@ -100,3 +104,3 @@ **Kind**: static method of [<code>typical</code>](#module_typical) | ||
### t.isArrayLike(input) ⇒ <code>boolean</code> | ||
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. | ||
An array-like value has all the properties of an array yet is not an array instance. An example is the `arguments` object. Returns `true`` if the input value is an object, not `null`` and has a `length` property set with a numeric value. | ||
@@ -138,2 +142,35 @@ **Kind**: static method of [<code>typical</code>](#module_typical) | ||
<a name="module_typical.isUndefined"></a> | ||
### t.isUndefined(input) ⇒ <code>boolean</code> | ||
Returns true if the input value is undefined. | ||
**Kind**: static method of [<code>typical</code>](#module_typical) | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| input | <code>\*</code> | the input to test | | ||
<a name="module_typical.isNull"></a> | ||
### t.isNull(input) ⇒ <code>boolean</code> | ||
Returns true if the input value is null. | ||
**Kind**: static method of [<code>typical</code>](#module_typical) | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| input | <code>\*</code> | the input to test | | ||
<a name="module_typical.isDefinedValue"></a> | ||
### t.isDefinedValue(input) ⇒ <code>boolean</code> | ||
Returns true if the input value is not one of `undefined`, `null`, or `NaN`. | ||
**Kind**: static method of [<code>typical</code>](#module_typical) | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| input | <code>\*</code> | the input to test | | ||
<a name="module_typical.isClass"></a> | ||
@@ -140,0 +177,0 @@ |
Sorry, the diff of this file is not supported yet
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
26217
530
303