UNPKG

gbox-notification

Version:

Email temaplates and notifications

25 lines (22 loc) 654 B
let _ = require('lodash'); module.exports = { groupEmails: function (emails) { /* Group emails by language and then flat emails only * expected output: * { * language : 'eng', * emails: ['test@gauss.hr', 'test2@gauss.hr'] * } */ let emailArray = []; let groupEmails = _.groupBy(emails, 'language'); _.each(groupEmails,(val,key) =>{ let obj = { language: key, emails: _.flatMap(val,'email') }; emailArray.push(obj); }); return emailArray; } };