Add unary

This commit is contained in:
Angelos Chalaris
2018-01-24 13:22:32 +02:00
parent 61d8093198
commit 315780ade3
2 changed files with 14 additions and 0 deletions

13
snippets/unary.md Normal file
View File

@ -0,0 +1,13 @@
### unary
Creates a function that accepts up to one argument, ignoring any additional arguments.
Call the provided function, `fn`, with just the first argument given.
```js
const unary = fn => val => fn(val);
```
```js
['6', '8', '10'].map(unary(parseInt)); // [6, 8, 10]
```