deepdash-es
Version:
➔ 𝐃eep extension for 𝐋odash-es: ✓ eachDeep ✓ filterDeep ✓ pickDeep ✓ omitDeep ✓ keysDeep ✓ index ✓ condenseDeep ⋮ Parent nodes tracking ⋮ Circular references check ⋮ Leaves only mode ⋮ Path as a valid js string or an array ⋮
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;