umbrella icon indicating copy to clipboard operation
umbrella copied to clipboard

[egf]: what to do with repeated node identifiers and properties?

Open nichtich opened this issue 4 years ago • 1 comments

Are repeated node identifiers merged, e.g.:

x
  foo 1  
  bar 2

x
  bar 2
  bar 3

Equivalent to?

x
  foo 1  
  bar 2
  bar 3

Merging requires a definition of sameness on combinations of property, tag, and value.

nichtich avatar Jul 23 '20 07:07 nichtich

Close! The merging behavior is that all IDs (nodes and properties) can be repeated but:

  • Node IDs will always refer to the same respective object.
  • Duplicated property IDs (irrespective of their values) will be merged into an array (without the Set-like semantics you seem to assume). The merging will only occur when the prop ID is encountered at least twice to avoid wrapping all prop values into an array (though I've considered this for uniformity in terms of later access patterns)

So the equivalent for the above would be:

x
    foo 1
    bar 2
    bar 2
    bar 3

and a resulting JS object:

{
    x: {
        foo: 1,
        bar: [2, 2, 3]
    }
}

postspectacular avatar Jul 23 '20 08:07 postspectacular