Created
November 28, 2019 14:27
-
-
Save Goloburda/c7b4c369205b042820747a5e440e8413 to your computer and use it in GitHub Desktop.
Allow to apply number of functions to passed argument.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fn1 = arg => arg.toUpperCase(); | |
const fn2 = arg => | |
arg | |
.split("") | |
.reverse() | |
.join(""); | |
const fn3 = arg => arg + "WoW"; | |
const fn4 = arg => arg.split(""); | |
const pipe = (...rest) => name => rest.reduce((acc, cur) => cur(acc), name); | |
const res = pipe( | |
fn1, | |
fn2, | |
fn3, | |
fn4 | |
)("Mikita"); | |
console.log(res); // ["A", "T", "I", "K", "I", "M", "W", "o", "W"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment