See the exact line of the reference implementation source code.
Deep merging algorithm
The stamp specification standardized the deep merging algorithm to, basically, this:
Plain objects are (recursively) deep merged, including ES6 Symbol keys, ES5 getters and setters.
Arrays are concatenated.
Functions, Symbols, RegExp, etc. values are copied by reference.
The last object type overwrites previous object type.
constMyStamp1=stampit()constdeepObject1= { [Symbol('foo')]: { one:'first' },// this plain object will be deep merged array: [0,'bar', () => {}, { obj:'my object' }],// this array will be concatenated with func: MyStamp1,// this stamp will be replaced with another stamp something: [42],// this array will be replaced with an object oldKey:'some value'}constMyStamp2=stampit()constdeepObject2= { [Symbol('foo')]: { two:'second' }, array: [0,'bar', { another:'object' }], func: MyStamp2, something: { [0]:42 }, newKey:'some value'}
The merged result of the two objects above will be this:
constdeepResult= { [Symbol('foo')]: { one:'first', two:'second' },// contains properties from both objects array: [0,'bar', () => {}, { obj:'my object' },0,'bar', { another:'object' }],// both arrays are here func: MyStamp2,// Stamp2 replaced the Stamp1 something: { [0]:42 },// the array was replaced with the object oldKey:'some value',// these two were simply carried across newKey:'some value'}
See the exact line of the reference implementation source code.