zents
Version:
ZenTS is a Node.js & TypeScript MVC-Framework for building rich web applications, released as free and open-source software under the MIT License. It is designed for building web applications with modern tools and design patterns.
18 lines • 771 B
JavaScript
;
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-call */
Object.defineProperty(exports, "__esModule", { value: true });
exports.get = void 0;
// Source: https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_get
function get(obj, path, defaultValue = undefined) {
const travel = (regexp) => {
return String.prototype.split
.call(path, regexp)
.filter(Boolean)
.reduce((res, key) => res !== null && res !== undefined ? res[key] : res, obj);
};
const result = travel(/[,[\]]+?/) || travel(/[,[\].]+?/);
return result === undefined || result === obj ? defaultValue : result;
}
exports.get = get;
//# sourceMappingURL=get.js.map