@modern-kit/utils
Version:
18 lines (15 loc) • 427 B
JavaScript
import { isNil } from '../../validator/isNil/index.mjs';
function get(obj, path, defaultValue) {
const paths = path.replace(/\?/g, "").split(".");
let result = obj;
for (let i = 0; i < paths.length; i++) {
const currentPath = paths[i];
if (isNil(result[currentPath])) {
return defaultValue;
}
result = result[currentPath];
}
return result;
}
export { get };
//# sourceMappingURL=index.mjs.map