deepdash
Version:
➔ 𝐃eep standalone lib / 𝐋odash extension: ✓ eachDeep ✓ filterDeep ✓ mapDeep ✓ reduceDeep ✓ pickDeep ✓ omitDeep ✓ keysDeep ✓ index ✓ condenseDeep ⋮ Parents stack ⋮ Circular check ⋮ Leaves only mode ⋮ Children mode ⋮ cherry-pick ⋮ esm
12 lines (10 loc) • 321 B
JavaScript
export default function getExists(_) {
function exists(obj, path) {
path = Array.isArray(path) ? _.clone(path) : _.toPath(path);
var key = path.pop();
var parent = path.length ? _.get(obj, path) : obj;
return parent !== undefined && key in parent;
}
return exists;
}
getExists.notChainable = true;