Update and rename coalesce-factory.md to coalesceFactory.md

This commit is contained in:
Angelos Chalaris
2017-12-18 12:15:36 +02:00
committed by GitHub
parent ff6ff9c4c8
commit 8f6a8f2143
2 changed files with 11 additions and 11 deletions

View File

@ -1,11 +0,0 @@
### Coalesce factory
Returns a customized coalesce function that returns the first argument
that returns true from the provided argument validation function.
```js
const coalesceFactory = valid => (...args) => args.find(valid)
// const customCoalesce = coalesceFactory(_ => ![null, undefined, "", NaN].includes(_))
// customCoalesce(undefined, null, NaN, "", "Waldo") //-> "Waldo"
```

View File

@ -0,0 +1,11 @@
### coalesceFactory
Returns a customized coalesce function that returns the first argument that returns `true` from the provided argument validation function.
Use `Array.find()` to return the first argument that returns `true` from the provided argument validation function.
```js
const coalesceFactory = valid => (...args) => args.find(valid);
// const customCoalesce = coalesceFactory(_ => ![null, undefined, "", NaN].includes(_))
// customCoalesce(undefined, null, NaN, "", "Waldo") //-> "Waldo"
```