This file contains hidden or 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 resolveUsers(users) { | |
| const resolveComments = createCommentsResolver(); | |
| return Promise.all( | |
| users.map(user => { | |
| return resolveComments(user) | |
| }) | |
| ); | |
| } |
This file contains hidden or 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 resolveUsers(users) { | |
| return Promise.all( | |
| users.map(user => { | |
| return resolveComments(user) | |
| }) | |
| ); | |
| } | |
| async function resolveComments(user) { | |
| user.comments = await Promise.all( |
This file contains hidden or 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
| [ | |
| { | |
| id: '8190834', | |
| commentIds: [ '0002434', '0002437', '0002440' ], | |
| comments: [ | |
| { | |
| id: '0002434', | |
| content: 'Awesome post!' | |
| }, | |
| { |
This file contains hidden or 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
| [ | |
| Promise { <pending> }, | |
| Promise { <pending> } | |
| ] |
This file contains hidden or 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 resolveComments(user) { | |
| return Promise.all( | |
| user.commentIds.map(commentId => { | |
| return comments.getCommentById(commentId) | |
| }) | |
| ); | |
| } | |
| const activeUsers = await post.getActiveUsers(); | |
| const activeUsersFullComments = activeUsers.map(async user => { |
This file contains hidden or 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
| [ | |
| { | |
| id: '8190834', | |
| commentIds: [ '0002434', '0002437', '0002440' ], | |
| comments: [ | |
| Promise { <pending> }, | |
| Promise { <pending> }, | |
| Promise { <pending> } | |
| ] | |
| }, |
This file contains hidden or 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 activeUsers = await post.getActiveUsers(); | |
| const activeUsersComments = activeUsers.map(user => { | |
| user.comments = user.commentIds.map(async commentId => { | |
| return await comments.getCommentById(commentId) | |
| }); | |
| return user; | |
| }); |
This file contains hidden or 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
| [ | |
| { | |
| id: '8190834', | |
| commentIds: [ '0002434', '0002437', '0002440' ] | |
| }, | |
| { | |
| id: '8190835', | |
| commentIds: [ '0002436', '0002437', '0002441' ] | |
| } | |
| ] |
This file contains hidden or 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 activeUsers = await post.getActiveUsers(); |
This file contains hidden or 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
| /** | |
| * A Go script that pulls Uber ride history and fare details | |
| * | |
| * Example: | |
| * $ go run concurrent_http.go | |
| * | |
| * New York | Base: $1.16 -- Duration Cost: $2.32 -- Distance Cost (mile): $4.53 -- Service Fees: $2.35 -- Duration: 13.67min | |
| * New Jersey | Base: $1.16 -- Duration Cost: $0.66 -- Distance Cost (mile): $1.83 -- Service Fees: $2.35 -- Duration: 3.88min | |
| * New Jersey | Base: $1.10 -- Duration Cost: $0.86 -- Distance Cost (mile): $1.94 -- Service Fees: $2.20 -- Duration: 5.40min | |
| * New Jersey | Base: $1.10 -- Duration Cost: $2.38 -- Distance Cost (mile): $1.47 -- Service Fees: $2.20 -- Duration: 14.87min |