@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/).
42 lines (41 loc) • 1.33 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;
}
exports.deepMergeObjects = deepMergeObjects;
exports.get = get;
exports.getPropertyValue = getPropertyValue;
//# sourceMappingURL=object-deb13c0b.js.map