@shopware-ag/meteor-component-library
Version:
The meteor component library is a Vue component library developed by Shopware. It is based on the [Meteor Design System](https://shopware.design/).
43 lines (42 loc) • 1.28 kB
JavaScript
const get = (obj, path, defValue) => {
if (!path)
return void 0;
const pathArray = Array.isArray(path) ? path : String(path).match(/([^[.\]])+/g);
if (!pathArray)
return void 0;
const result = pathArray.reduce((prevObj, key) => prevObj && prevObj[key], obj);
return result === void 0 ? defValue : result;
};
function getPropertyValue(object, propertyPath, defaultValue) {
if (!propertyPath) {
return object;
}
if (Array.isArray(propertyPath)) {
for (const path of propertyPath) {
const value = get(object, path, "");
if (value !== void 0 && value !== null && value !== "") {
return value;
}
}
return defaultValue;
}
return get(object, propertyPath, defaultValue);
}
function deepMergeObjects(target, source) {
for (const key in source) {
const targetValue = target[key];
const sourceValue = source[key];
if (sourceValue instanceof Object && !Array.isArray(sourceValue) && targetValue instanceof Object && !Array.isArray(targetValue)) {
target[key] = deepMergeObjects(targetValue, sourceValue);
} else {
target[key] = sourceValue;
}
}
return target;
}
export {
get as a,
deepMergeObjects as d,
getPropertyValue as g
};
//# sourceMappingURL=object-e11d5dd3.mjs.map