Add mapString, fix dig

This commit is contained in:
Angelos Chalaris
2018-07-14 10:59:56 +03:00
parent c4c4a39a30
commit 005dfcf8d0
7 changed files with 1601 additions and 1551 deletions

View File

@ -1,15 +1,10 @@
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;
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;