Skip to content

Instantly share code, notes, and snippets.

@dmikey
Created March 12, 2015 18:22
Show Gist options
  • Save dmikey/a679499fcc2175374bd7 to your computer and use it in GitHub Desktop.
Save dmikey/a679499fcc2175374bd7 to your computer and use it in GitHub Desktop.
function merge(target, src) {
//quickly merge all values from
//retrieved data into the store
Object.keys(src).forEach(function (key) {
if (typeof src[key] !== 'object' || !src[key]) {
target[key] = src[key];
} else {
if (!target[key]) {
target[key] = src[key];
} else {
target[key] = merge(target[key], src[key]);
}
}
});
return target;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment