@opentiny/fluent-editor
Version:
A rich text editor based on Quill 2.0, which extends rich modules and formats on the basis of Quill. It's powerful and out-of-the-box.
28 lines (27 loc) • 839 B
JavaScript
function merge(target, ...sources) {
if (!sources.length) return target;
const isObject = (obj) => obj !== null && (typeof obj === "object" || typeof obj === "function");
const isPlain = (obj) => {
if (!isObject(obj)) return false;
const proto = Object.getPrototypeOf(obj);
return proto === Object.prototype || proto === null;
};
for (const src of sources) {
if (!isObject(src)) continue;
for (const key in src) {
if (!Object.prototype.hasOwnProperty.call(src, key)) continue;
const oldVal = target[key];
const newVal = src[key];
if (isPlain(newVal) && (oldVal === void 0 || isPlain(oldVal))) {
target[key] = merge(oldVal || {}, newVal);
} else {
target[key] = newVal;
}
}
}
return target;
}
export {
merge
};
//# sourceMappingURL=merge.es.js.map