Safely get a dot-notated path within a nested object.
Smallest possible implementation: only 120 bytes.
You could write this yourself, but then you'd have to write tests.
Implementation is ripped directly from preact.
Supports ES Modules, CommonJS and globals.
npm install --save dlv
import delve from 'dlv';
let obj = {
a: {
b: {
c: 1
}
}
};
delve(obj, 'a.b.c') === 1;
delve(obj, 'a.b') === obj.a.b;
delve(obj, 'a.b.c.d') === undefined;MIT