Skip to content

Instantly share code, notes, and snippets.

@dance2die
Created June 16, 2018 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dance2die/6ef5401930840c141464a2e2965af038 to your computer and use it in GitHub Desktop.
Save dance2die/6ef5401930840c141464a2e2965af038 to your computer and use it in GitHub Desktop.
// Build item details map
// for an O(1) look up for fetched item details
const items = (await getStories(storyIds))
.map(res => res.data)
.filter(item => item !== null)
.reduce((acc, item) => acc.set(item.id, item), new Map())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment