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 fetchSoccerResults = fetchSoccerResultsFromResource( ... ); | |
const loadSoccerMatchesToVariable = function( _soccerMatches ) { | |
soccerMatches = _soccerMatches; | |
}; | |
const loadSoccerResultsToVariable = function( _soccerResults ) { | |
soccerResults = _soccerResults; | |
} | |
const mapDetailedMatches = function(){ | |
return soccerMatches.map(function( match ) { |
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
... | |
fetchSoccerMatchesFromResource( ... ); | |
.then( addToCache ) | |
.then( filterMatchesFrom( 'Germany' ) ) | |
}) | |
.catch( printError ); | |
... |
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
... | |
fetchSoccerMatchFromResource() | |
.then(function( match ) { | |
if ( cachedDetails[ match.id ] ) { | |
// Returns the resolved data | |
return cachedDetails[ match.id ]; | |
} | |
// Returns a Promise | |
return fetchMatchDetails( match.id ); |
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 mapDetailedMatches = function( soccerMatches, soccerResults ){ | |
return soccerMatches.map(function( match ) { | |
return { | |
name: match.name, | |
score: findScoreForMatch( match, soccerResults ) | |
}; | |
}); | |
}; | |
const printDetailedMatchesToScreen = function( detailedMatches ) { | |
detailedMatches.forEach(function( detailedMatch ) { |
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 _ = require('lodash'); | |
const moment = require('moment'); |
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 _ = require('lodash'); | |
const moment = require('moment'); | |
const readableStream = require('readable-stream'); |
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 _ = require('lodash'); | |
const moment = require('moment'); | |
+ const readableStream = require('readable-stream'); |
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 _ = require('lodash'); | |
- const moment = require('moment'); | |
+ const _ = require('lodash'); | |
+ const moment = require('moment'); | |
+ const readableStream = require('readable-stream'); |
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 user = { | |
age : 25, | |
name : 'John', | |
surname : 'Doe', | |
}; |
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 promisify = require("bluebird").promisify; | |
const readFile = promisify(require("fs").readFile); | |
const writeFile = promisify(require("fs").writeFile); | |
const flattenArray = require("flatten-array"); | |
module.exports = function flattenArrayInsideFile(fileName) { | |
return readFile(fileName, "UTF-8") | |
.then(function(fileContent) { | |
const array = JSON.parse(fileContent); | |
const flattenedArray = flattenArray(array); |