Created
March 12, 2015 18:22
-
-
Save dmikey/a679499fcc2175374bd7 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
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