This commit is contained in:
Angelos Chalaris
2018-01-23 21:02:17 +02:00
parent 93351b4b8e
commit 0e2475f480
2 changed files with 15 additions and 0 deletions

14
snippets/over.md Normal file
View File

@ -0,0 +1,14 @@
### over
Creates a function that invokes each provided function with the arguments it receives and returns the results.
Use `Array.map()` and `Function.apply()` to apply each function to the given arguments.
```js
const over = (...fns) => (...args) => fns.map(fn => fn.apply(null, args));
```
```js
const minMax = over(Math.min, Math.max);
minMax(1,2,3,4,5); // [1,5]
```