Skip to content

Instantly share code, notes, and snippets.

@varpa89
Created June 8, 2016 11:18
Show Gist options
  • Save varpa89/33b5ba7c5727620e2485dca419346fda to your computer and use it in GitHub Desktop.
Save varpa89/33b5ba7c5727620e2485dca419346fda to your computer and use it in GitHub Desktop.
childDeepClone: function (child) {
var childCopy = _.pick(child, 'lastName', 'firstName', 'middleName', 'birthDate', 'gender', 'birthPlace', 'snils');
if (_.isArray(child.addressList)) {
var addressCopy = [];
_.each(child.addressList, function (address) {
if (address) {
addressCopy.push(_.pick(address, 'postalCode', 'fullAddress', 'fullHouse', 'addressUID', 'houseUID', 'plain', 'oktmo', 'flat', 'type'));
} else {
addressCopy.push(null);
}
});
childCopy.addressList = addressCopy;
}
if (_.isArray(child.documentList)) {
var documentCopy = [];
_.each(child.documentList, function (document) {
documentCopy.push(_.pick(document, 'type', 'series', 'number', 'dateObtain', 'source'));
});
childCopy.documentList = documentCopy;
}
return childCopy;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment