Data
UpSetJS requires sets and optionally combinations of sets as input. There are some utility function to help creating the required data structures:
extractSets<T extends { sets: string[] }>(elements: readonly T[]): ISet<T>[]given an array of elements where each is having a property called.setscontaining a list of set names in which this element is part of. e.g.{ sets: ['Blue Hair', 'Female']}. The return value is a list of sets in the required data structures and having a.elemswith an array of the input elements.asSets<T, S extends { name: string; elems: readonly T[] }>(sets: readonly S[]): (S & ISet<T>)[]extends the given basic set objects (nameandelems) with the required attributes forUpSetJSgenerateCombinations<T>(sets: ISets<T>, { type = 'intersection', min = 0, max = Infinity, empty = false } = {}): ISetCombination<T>[]one needs to generate the list of the combinations to show in case of customized sorting or filtering. This function takes the array of sets as input and computed all possible set intersections (aka. power set). The options allow to limit the generation to skipemptyset combinations or enforce a minimum/maximum amount of sets in the set combinations. There are three types:intersectionto generate set intersections,unionfor set unions, anddistinctIntersectionfor set intersections that do not appear in any other set