Merge pull request #307 from skatcat31/feature/adapters/spread

[FEATURE] add spreadOver snippet
This commit is contained in:
David Wu
2017-12-22 14:56:22 +01:00
committed by GitHub
2 changed files with 15 additions and 0 deletions

14
snippets/spreadOver.md Normal file
View File

@ -0,0 +1,14 @@
### spreadOver
Takes a veriadic function and returns a closure that accepts an array of arguments to map to the inputs of the function.
Use closures and the spread operator (`...`) to map the array of arguments to the inputs of the function.
```js
const spreadOver = fn => argsArr => fn(...argsArr);
/*
const arrayMax = spreadOver(Math.max)
arrayMax([1,2,3]) // -> 3
arrayMax([1,2,4]) // -> 4
*/
```

View File

@ -105,6 +105,7 @@ similarity:array
sleep:function sleep:function
sortCharactersInString:string sortCharactersInString:string
speechSynthesis:media speechSynthesis:media
spreadOver:adapter
standardDeviation:math standardDeviation:math
symmetricDifference:array symmetricDifference:array
tail:array tail:array