index.js 515 B

123456789101112131415161718
  1. import templateConfig from "./template";
  2. import defaultConfig from "./default";
  3. function replaceObject(toReplace, toReplaceWith) {
  4. const toReplaceObj = toReplace;
  5. Object.keys(toReplaceWith).forEach((key) => {
  6. const value = toReplaceWith[key];
  7. if (!value) return;
  8. if (typeof value === "object") {
  9. toReplaceObj[key] = replaceObject(toReplace[key], toReplaceWith[key]);
  10. } else {
  11. toReplaceObj[key] = value;
  12. }
  13. });
  14. return toReplaceObj;
  15. }
  16. export default replaceObject(templateConfig, defaultConfig);