Skip to content

Instantly share code, notes, and snippets.

@tkh44
Last active December 22, 2015 10:18
Show Gist options
  • Select an option

  • Save tkh44/6457505 to your computer and use it in GitHub Desktop.

Select an option

Save tkh44/6457505 to your computer and use it in GitHub Desktop.
Abuse underscore
self.reset(_.map(_.filter(contacts, function(contact) {
return contact.emails && contact.emails.length;
}), function(contact) {
var name = contact.name,
email;
email = _.findWhere(contact.emails, {'type': 'work'}) || contact.emails[0];
return {
firstName: name.givenName || '',
lastName: name.familyName || '',
email: email.value
}
}
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment