a zip code crypto-currency system good for red ONLY

1234567891011121314151617181920212223242526272829303132333435
  1. function override(source1, source2) {
  2. var target = {};
  3. var key1;
  4. var key2;
  5. var item;
  6. for (key1 in source1) {
  7. item = source1[key1];
  8. if (Array.isArray(item)) {
  9. target[key1] = item.slice(0);
  10. } else if (typeof item == 'object' && item !== null) {
  11. target[key1] = override(item, {});
  12. } else {
  13. target[key1] = item;
  14. }
  15. }
  16. for (key2 in source2) {
  17. item = source2[key2];
  18. if (key2 in target && Array.isArray(item)) {
  19. target[key2] = item.slice(0);
  20. } else if (key2 in target && typeof item == 'object' && item !== null) {
  21. target[key2] = override(target[key2], item);
  22. } else {
  23. target[key2] = item;
  24. }
  25. }
  26. return target;
  27. }
  28. module.exports = override;