Last active
May 5, 2019 23:46
-
-
Save matthewstokeley/175303413a07445a36383c9c9ab8a55d to your computer and use it in GitHub Desktop.
chain a sequence of functions
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 chain = (array, arg) => { | |
let res = arg | |
? arg | |
: '' | |
for (let i = 0; i < array.length; ++i) { | |
res = array[i].call(this, res); | |
} | |
return res; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment