@signaldb/core
Version:
SignalDB is a client-side database that provides a simple MongoDB-like interface to the data with first-class typescript support to achieve an optimistic UI. Data persistence can be achieved by using storage providers that store the data through a JSON in
19 lines (18 loc) • 409 B
JavaScript
;
function get(value, path) {
const segments = path.split(/[.[\]]/g);
if (segments[0] === "")
segments.shift();
if (segments.at(-1) === "")
segments.pop();
let current = value;
for (const key of segments) {
if (current == null || key.trim() === "")
return;
current = current[key];
}
if (current === void 0)
return;
return current;
}
module.exports = get;