Skip to content

Standardized merge algorithm

Compare
Choose a tag to compare
@koresar koresar released this 27 Jul 11:13
· 33 commits to master since this release

In this release the deep merging algorithm has been standardised. It is:

  • Plain objects are deeply merged.
  • Array are concatenated.
  • Everything else (including Symbols) is copied by assignment.
const ReferencedStamp = compose();

const FirstStamp = compose({deepProperties: {
  anotherStamp: null
}});
const SecondStamp = compose({deepProperties: {
  anotherStamp: ReferencedStamp
}});
const CombinedStamp = compose(FirstStamp, SecondStamp);

const stampFromMetadata = CombinedStamp.compose.deepProperties.anotherStamp;

Previously the stampFromMetadata was a POJO:
Object.getPrototypeOf(stampFromMetadata) === Object.prototype

With this release it will be copied by reference:
stampFromMetadata === ReferencedStamp