Skip to content

Commit

Permalink
Add polyfills for Set intersection and union
Browse files Browse the repository at this point in the history
  • Loading branch information
dougy83 committed Mar 1, 2024
1 parent 0b3ed3b commit c805d40
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions web/src/componentTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ import { naturalCompare } from '@discoveryjs/natural-compare';

enableMapSet();

// polyfill for sets - union/intersection only available on latest browsers
Set.prototype.intersection ??= function (b) {
return new Set(this.values().filter(it => b.has(it)));
}
Set.prototype.union ??= function (b) {
return new Set(Array.from(this).concat(Array.from(b)));
}


function getValue(value) {
return value?.[0];
}
Expand Down

0 comments on commit c805d40

Please sign in to comment.