Set Helpers
Utility functions for working with set operations.
Functions
Section titled “Functions”| Function | Description |
|---|---|
countBy | Groups the values of a Set by a derived key and counts how many fall into each group. |
difference | native JS Set.prototype.difference() (ES2025 (Set methods)) |
filter | Creates a new Set containing only the values for which the predicate returns true. |
forEach | native JS Set.prototype.forEach((value, value2, set) => ...) (ES2015) |
groupBy | native JS Map.groupBy(set.values(), fn) (ES2024) |
intersection | native JS Set.prototype.intersection() (ES2025 (Set methods)) |
map | Creates a new Set with each value transformed by a function. |
map / filter | native JS new Set(set.values().map(fn)) / new Set(set.values().filter(fn)) (ES2025 (Iterator Helpers)) |
reduce / some / every / find | native JS set.values().reduce(fn, init) / .some(fn) / .every(fn) / .find(fn) (ES2025 (Iterator Helpers)) |
symmetricDifference | native JS Set.prototype.symmetricDifference() (ES2025 (Set methods)) |
toMapByKey | Builds a Map from a Set, keyed by a derived key. |
union | native JS Set.prototype.union() (ES2025 (Set methods)) |