merge.ts 419 B

12345678910111213
  1. export function merge(target: any, source: any) {
  2. Object.keys(source).forEach(function (key) {
  3. if (
  4. source.hasOwnProperty(key) && // Check if the property is not inherited
  5. source[key] &&
  6. typeof source[key] === "object" || key === "__proto__" || key === "constructor"
  7. ) {
  8. merge((target[key] = target[key] || {}), source[key]);
  9. return;
  10. }
  11. target[key] = source[key];
  12. });
  13. }