UNPKG

@arco-vue-pro-components/pro-components

Version:
27 lines (26 loc) 688 B
"use strict"; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); var is = require("./is.js"); const getValueByPath = (obj, path) => { if (!obj || !path) { return void 0; } path = path.replace(/\[(\w+)\]/g, ".$1"); const keys = path.split("."); if (keys.length === 0) { return void 0; } let temp = obj; for (let i = 0; i < keys.length; i++) { if (!is.isObject(temp) && !is.isArray(temp) || !keys[i]) { return void 0; } if (i !== keys.length - 1) { temp = temp[keys[i]]; } else { return temp[keys[i]]; } } return void 0; }; exports.getValueByPath = getValueByPath;