Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# koalas [](https://www.npmjs.com/package/koalas) [](https://npmjs.org/package/koalas) [](https://npmjs.org/package/koalas) [](https://travis-ci.org/doowb/koalas) [](https://ci.appveyor.com/project/doowb/koalas)
> Coalesce for JavaScript. Returns the first value that is not undefined or null.
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm install --save koalas
```
## Usage
```js
var koalas = require('koalas');
```
## API
### [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). If no values are valid, then the last argument is returned.
**Params**
* `arguments` **{Mixed}**: Pass in any amount of arguments.
* `returns` **{Mixed}**: First valid value.
**Example**
```js
console.log(koalas(undefined, null, NaN, 'a', 'b'));
//=> 'a'
console.log(koalas(undefined, null, NaN, {a: 'b'}, 'b'));
//=> {a: 'b'}
console.log(koalas(undefined, null, NaN, ['a', 'b', 'c'], {a: 'b'}, 'b'));
//=> ['a', 'b', 'c']
console.log(koalas(undefined, NaN, null));
//=> null
```
## About
### Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
### Contributors
| **Commits** | **Contributor** |
| --- | --- |
| 39 | [doowb](https://github.com/doowb) |
| 1 | [jonschlinkert](https://github.com/jonschlinkert) |
### Building docs
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
To generate the readme, run the following command:
```sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```
### Running tests
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:
```sh
$ npm install && npm test
```
### Author
**Brian Woodward**
* [github/doowb](https://github.com/doowb)
* [twitter/doowb](https://twitter.com/doowb)
### License
Copyright © 2017, [Brian Woodward](https://github.com/doowb).
Released under the [MIT License](LICENSE).
***
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.3, on April 18, 2017._