MarcelWaldvogel / vcard4-ts

A vCard 4.0 library with type safety first
MIT License
18 stars 3 forks source link

Better support for property groups #1

Closed MarcelWaldvogel closed 2 years ago

MarcelWaldvogel commented 3 years ago

Two approaches

  1. Have an extra groups?: Record<string, PartialVCard>; property on vCards, which includes the grouped properties. Then, user code could decide whether it wants
    • Items ungrouped: Just use the pre-existing structure, ignoring group field in properties, or
    • Items grouped: Read through groups and then ignore all values which have a group field
  2. Have a groupVCard() function, which groups all entries by group name (and those without, into ungrouped) into a Record<string, PartialVCard>

I am currently favoring 2, as groups are rarely used and most consumers will not want to bother about it. This also reduces code size for group-agnostic consumers.