This commit is contained in:
Henry Szeto
2018-07-12 23:03:05 -07:00
parent 9176acf753
commit fdcf0fb929
2 changed files with 37 additions and 1 deletions

View File

@ -1 +1,11 @@
const dig = (obj, target) =>
target in obj
? obj[target]
: Object
.values(obj)
.reduce((acc, val) => {
if (acc !== undefined) return acc;
if (typeof val === 'object') return dig(val, target);
}, undefined);
module.exports = dig;