A Pen by Michael Russell on CodePen.
Last active
April 19, 2016 23:57
-
-
Save subhaze/4f62ed62303a06051d6767410c98ca09 to your computer and use it in GitHub Desktop.
pipeline [Array#reduce]
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
<pre style="padding: 20px"><code class="hljs js"> | |
function pipeline(data, ...fns){ | |
return fns.reduce((acc, curr) => curr(acc), data); | |
} | |
let abc = pipeline('a', (v)=>v+'b', (v)=>v+'c'); | |
console.log(abc); | |
// "abc" | |
</code></pre> |
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
function pipeline(data, ...fns){ | |
return fns.reduce((acc, curr) => curr(acc), data); | |
} | |
let abc = pipeline('a', (v)=>v+'b', (v)=>v+'c'); | |
console.log(abc); | |
hljs.initHighlightingOnLoad() |
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
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.3.0/highlight.min.js"></script> |
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
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.3.0/styles/default.min.css" rel="stylesheet" /> | |
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.3.0/styles/tomorrow-night-eighties.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment