Last active
March 17, 2017 09:29
-
-
Save yellowred/5fe3c82296ff6be9e74ac0fae83d8dbb to your computer and use it in GitHub Desktop.
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
et generateResponse = (data) => { | |
return Promise.coroutine(function* () { | |
let emails = data | |
.map(getEmailsFromIndividual) | |
.reduce(flatten) | |
return emails | |
})() | |
} | |
let getEmailsFromIndividual = (individual) => { | |
if (!Array.isArray(individual.contacts)) return [] | |
return individual | |
.contacts | |
.map(value => value['emailAddress']) | |
} | |
let flatten = (flatArray, arrayElement) => { | |
return flatArray.concat(arrayElement) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment