Blame view

node_modules/coalescy/README.md 806 Bytes
ce4c83ff   wxy   初始提交
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
  [![NPM Version](http://img.shields.io/npm/v/coalescy.svg?style=flat)](https://npmjs.org/package/coalescy)
  [![Build Status](http://img.shields.io/travis/royriojas/coalescy.svg?style=flat)](https://travis-ci.org/royriojas/coalescy)
  
  # coalescy
  > Simple function that return the first non null or undefined argument passed to it
  
  ## Install
  
  ```bash
  npm i --save coalescy
  ```
  
  ## Usage
  
  `coalescy` simply return the first non nully of the passed elements. Null if all the values are null
  
  it works the same as
  
  ```javascript
  a || b
  ```
  
  but it works on falsie values too
  
  ## Example
  
  ```javascript 
  var clsc = require('coalescy');
  var obj = clsc(null, []); // obj = [];
  obj = clsc(null, {}); // obj = {};
  obj = clsc(null, [], {}); // obj = []; // the first non null
  obj = clsc(null, undefined, 0, []) // 0
  ```