Skip to content

Instantly share code, notes, and snippets.

@FagnerMartinsBrack
Last active May 2, 2016 08:36
Show Gist options
  • Save FagnerMartinsBrack/055ab2e73b793e2f8739 to your computer and use it in GitHub Desktop.
Save FagnerMartinsBrack/055ab2e73b793e2f8739 to your computer and use it in GitHub Desktop.
(Medium) Promises Are Not Proxies - Ideal World
try {
const soccerMatches = fetchSoccerMatchesFromResource( ... );
const soccerResults = fetchSoccerResultsFromResource( ... );
const detailedMatches = soccerMatches.map(function( match ) {
return {
name: match.name,
score: findScoreForMatch( match, soccerResults )
};
});
detailedMatches.forEach(function( detailedMatch ) {
const name = detailedMatch.name;
const score = detailedMatch.score;
console.log( `${name} with the score ${score}` );
});
} catch ( err ) {
console.error( 'Failed to print the score', err );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment