Last active
December 14, 2020 23:59
-
-
Save sudomann/d2f56cec7b170c5e380050d60331b552 to your computer and use it in GitHub Desktop.
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 transformContact = (contact) => { | |
const obj = {}; | |
[ | |
Contacts.Fields.Name, | |
Contacts.Fields.Nickname, | |
Contacts.Fields.MaidenName, | |
].forEach((fieldName) => { | |
if (contact[fieldName]) obj[fieldName] = contact[fieldName]; | |
}); | |
if (contact[Contacts.Fields.Emails]) | |
obj[Contacts.Fields.Emails] = transformEmails( | |
contact[Contacts.Fields.Emails], | |
); | |
if (contact[Contacts.Fields.PhoneNumbers]) | |
obj[Contacts.Fields.PhoneNumbers] = transformPhoneNumbers( | |
contact[Contacts.Fields.PhoneNumbers], | |
); | |
return obj; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment