Improve filter callback

This commit is contained in:
Peter Maquiran
2022-01-10 22:04:04 +01:00
parent 053c6034a7
commit d04a57b35c
6 changed files with 120 additions and 123 deletions
+18
View File
@@ -0,0 +1,18 @@
function deepFind(obj, path) {
var paths = path.split('.')
, current = obj
, i;
for (i = 0; i < paths.length; ++i) {
if (current[paths[i]] == undefined) {
return undefined;
} else {
current = current[paths[i]];
}
}
return current;
}
module.exports = {
deepFind: deepFind,
};