-
-
Save mcsf/bed3a2ae215803d09a5b to your computer and use it in GitHub Desktop.
Illustrates a point at https://miguelcsf.wordpress.com/2015/05/12/long-anonymous-chains-of-things/
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
var isPopular = ( post ) => post.popularity > 9000; | |
var topPosts = map( getPosts(), compose( | |
partial( takeWhile, isPopular ), | |
partial( sortBy, 'popularity' ) ); | |
// versus | |
var topPosts = []; | |
var posts = getPosts(); | |
posts = sortBy( 'popularity', posts ); | |
forEach( posts, function( post ) { | |
// only keep popular posts | |
if ( post.popularity > 9000 ) { | |
topPosts.push( post ); | |
} | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment