daily pastebin goal
15%
SHARE
TWEET

Untitled

a guest Dec 7th, 2017 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var utils = require('./utils');
  2.  
  3. var base = {
  4.   a: {
  5.     b: {
  6.       c: 2
  7.     }
  8.   },
  9.   d: 'd'
  10. };
  11.  
  12. var custom = { d: 'new value' };
  13.  
  14. var sep = '---------';
  15.  
  16. console.log(base, sep, custom);
  17.  
  18. console.log('merge base with custom');
  19.  
  20. var merged = utils.merge(base, custom);
  21.  
  22. console.log(base, sep, custom, sep, merged);
  23.  
  24. merged.a.b.c = 4;
  25. console.log('set merged.a.b.c = 4')
  26.  
  27. console.log(base, sep, custom, sep, merged);
  28.  
  29. // console output
  30. // { a: { b: { c: 2 } }, d: 'd' } '---------' { d: 'new value' }
  31. // merge base with custom
  32. // { a: { b: { c: 2 } }, d: 'd' } '---------' { d: 'new value' } '---------' { a: { b: { c: 2 } }, d: 'new value' }
  33. // set merged.a.b.c = 4
  34. // { a: { b: { c: 4 } }, d: 'd' } '---------' { d: 'new value' } '---------' { a: { b: { c: 4 } }, d: 'new value' }
RAW Paste Data
Top