Skip to content

Commit

Permalink
📝 Add documentation
Browse files Browse the repository at this point in the history
Signed-off-by: Saran Tanpituckpong <sarunta@gmail.com>
  • Loading branch information
gluons committed May 5, 2017
1 parent c21da0a commit 5c7fe4e
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,26 @@ yarn add fnvl

```javascript
const fnvl = require('fnvl');
...

function someFn() {
// ...
}

// When a value is not Function, it will return fallback value.
let a = fnvl(10, 'x'); // a = 'x'
let b = fnvl([1, 2, 3], console.log); // b = console.log

// When a value is Function, it will return that value.
let c = fnvl(console.error, 1); // c = console.error
let d = fnvl(someFn, () => {}); // d = someFn
```

## API

### fnvl(value, fallbackValue)

#### value
A main value.

#### fallbackValue
A fallback value.

0 comments on commit 5c7fe4e

Please sign in to comment.