koalas
Advanced tools
Comparing version 1.0.1 to 1.0.2
12
index.js
@@ -6,2 +6,3 @@ 'use strict'; | ||
* A valid value is one that is not undefined, not null and not NaN (not a number). | ||
* If no values are valid, then the last argument is returned. | ||
* | ||
@@ -17,3 +18,7 @@ * ```js | ||
* //=> ['a', 'b', 'c'] | ||
* | ||
* console.log(koalas(undefined, NaN, null)); | ||
* //=> null | ||
* ``` | ||
* @name koalas | ||
* @param {Mixed} `arguments` Pass in any amount of arguments. | ||
@@ -26,4 +31,5 @@ * @return {Mixed} First valid value. | ||
var len = arguments.length; | ||
var arg; | ||
for (var i = 0; i < len; i++) { | ||
var arg = arguments[i]; | ||
arg = arguments[i]; | ||
if (hasValue(arg)) { | ||
@@ -33,7 +39,7 @@ return arg; | ||
} | ||
return null; | ||
return arg; | ||
} | ||
/** | ||
* Check to see if a value actual has a valid value: | ||
* Check to see if a value actually has a valid value: | ||
* - not undefined | ||
@@ -40,0 +46,0 @@ * - not null |
{ | ||
"name": "koalas", | ||
"description": "Coalesce for JavaScript. Returns the first value that is not undefined or null.", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"homepage": "https://github.com/doowb/koalas", | ||
"author": "Brian Woodward (https://github.com/doowb)", | ||
"contributors": [ | ||
"Brian Woodward <brian.woodward@gmail.com> (https://github.com/doowb)", | ||
"Brian Woodward <brian.woodward@gmail.com> (https://twitter.com/doowb)", | ||
"Jon Schlinkert <jon.schlinkert@sellside.com> (http://twitter.com/jonschlinkert)" | ||
@@ -10,0 +10,0 @@ ], |
@@ -21,5 +21,5 @@ # koalas [![NPM version](https://img.shields.io/npm/v/koalas.svg?style=flat)](https://www.npmjs.com/package/koalas) [![NPM monthly downloads](https://img.shields.io/npm/dm/koalas.svg?style=flat)](https://npmjs.org/package/koalas) [![NPM total downloads](https://img.shields.io/npm/dt/koalas.svg?style=flat)](https://npmjs.org/package/koalas) [![Linux Build Status](https://img.shields.io/travis/doowb/koalas.svg?style=flat&label=Travis)](https://travis-ci.org/doowb/koalas) [![Windows Build Status](https://img.shields.io/appveyor/ci/doowb/koalas.svg?style=flat&label=AppVeyor)](https://ci.appveyor.com/project/doowb/koalas) | ||
### [koalas](index.js#L22) | ||
### [koalas](index.js#L27) | ||
Coalesce function to find the first valid value. A valid value is one that is not undefined, not null and not NaN (not a number). | ||
Coalesce function to find the first valid value. A valid value is one that is not undefined, not null and not NaN (not a number). If no values are valid, then the last argument is returned. | ||
@@ -42,2 +42,5 @@ **Params** | ||
//=> ['a', 'b', 'c'] | ||
console.log(koalas(undefined, NaN, null)); | ||
//=> null | ||
``` | ||
@@ -55,3 +58,3 @@ | ||
| --- | --- | | ||
| 33 | [doowb](https://github.com/doowb) | | ||
| 39 | [doowb](https://github.com/doowb) | | ||
| 1 | [jonschlinkert](https://github.com/jonschlinkert) | | ||
@@ -71,3 +74,3 @@ | ||
Install dev dependencies: | ||
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command: | ||
@@ -88,6 +91,6 @@ ```sh | ||
Copyright © 2017, [Brian Woodward](https://github.com/doowb). | ||
Released under the MIT license. | ||
Released under the [MIT License](LICENSE). | ||
*** | ||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.2, on February 21, 2017._ | ||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.3, on April 18, 2017._ |
Sorry, the diff of this file is not supported yet
6465
52
91