Merging algorithm

When composing stamps you actually merge their descriptors (aka metadata).

The Object.assign is used for these descriptor properties:

The special deep merging algorithm (see below) is used for these descriptor properties:

The array concatenation and deduplication (see below) is used for these descriptor properties:

Array concatenation and deduplication

This is how initializers and composers metadata gets merged.

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.

The merged result of the two objects above will be this:

See the exact line of the reference implementation source code.

Last updated