Skip to content

Instantly share code, notes, and snippets.

@davidseek
Last active January 28, 2021 21:33
Show Gist options
  • Select an option

  • Save davidseek/03d9c8d3fefeb111fce30802aa124b4f to your computer and use it in GitHub Desktop.

Select an option

Save davidseek/03d9c8d3fefeb111fce30802aa124b4f to your computer and use it in GitHub Desktop.
Push Notifications Lodash
// Import statement to use lodash
const _ = require('lodash')
/**
* Converts the array to an array per userID
* @param tasks Tasks to convert
* @returns a dictionary of [userID: [Task]]
*/
function getFormatted(tasks: Task[]): { [userID: string]: Task[]; } {
// Use lodash function groupBy.
// Pass it the Array, and the key.
return _.groupBy(tasks, 'userID')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment