Files
30-seconds-of-code/snippets/over.md
30secondsofcode 1c4cffc021 Travis build: 1354
2018-01-23 19:03:54 +00:00

15 lines
380 B
Markdown

### 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]
```