Add mapString, fix dig
This commit is contained in:
@ -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;
|
||||
Reference in New Issue
Block a user