vditor
Version:
♏ 易于使用的 Markdown 编辑器,为适配不同的应用场景而生
19 lines (18 loc) • 564 B
text/typescript
export const merge = (...options: any[]) => {
const target: any = {};
const merger = (obj: any) => {
for (const prop in obj) {
if (obj.hasOwnProperty(prop)) {
if (Object.prototype.toString.call(obj[prop]) === "[object Object]") {
target[prop] = merge(target[prop], obj[prop]);
} else {
target[prop] = obj[prop];
}
}
}
};
for (let i = 0; i < options.length; i++) {
merger(options[i]);
}
return target;
};