Skip to content

Instantly share code, notes, and snippets.

@juliandescottes
Last active Aug 29, 2015
Embed
What would you like to do?
getPath
module.exports = function (object, path) {
var parts = path.split ? path.split(".") : path;
try {
var node = object;
parts.forEach(function (part) {
node = node[part];
});
return node;
} catch (e) {
console.error('Failed to get path : ' + path + ' in object : \n' + JSON.stringify(object));
return null;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment