move the pollyfills

This commit is contained in:
MathMan05
2025-10-29 15:34:44 -05:00
parent 345d4535d3
commit 2d0591aba0
3 changed files with 40 additions and 38 deletions

View File

@@ -38,44 +38,7 @@ type favandfreqimp = Omit<
| "heard_sound_frecency"
| "played_sound_frecency"
>;
Set.prototype.intersection ||= function <T>(set: Set<T>) {
const newSet = new Set();
for (const elm of this) {
if (set.has(elm)) {
newSet.add(elm);
}
}
return newSet;
};
Set.prototype.difference ||= function <T>(set: Set<T>) {
const newSet = new Set();
for (const elm of this) {
if (!set.has(elm)) {
newSet.add(elm);
}
}
return newSet;
};
Set.prototype.symmetricDifference ||= function <T>(set: Set<T>) {
const newSet = new Set();
for (const elm of this) {
if (!set.has(elm)) {
newSet.add(elm);
}
}
for (const elm of set) {
if (!this.has(elm)) {
newSet.add(elm);
}
}
return newSet;
};
Set.prototype.isDisjointFrom ||= function <T>(set: Set<T>) {
return this.symmetricDifference(set).size === 0;
};
Set.prototype.union ||= function <T>(set: Set<T>) {
return new Set([...this, ...set]);
};
export class Favorites {
owner: Localuser;
// ----- stuff that needs to store ----

View File

@@ -6,6 +6,7 @@ import {MarkDown} from "./markdown.js";
import {Message} from "./message.js";
import {File} from "./file.js";
import {I18n} from "./i18n.js";
import "./utils/pollyfills.js";
if (window.location.pathname === "/app") {
window.location.pathname = "/channels/@me";
}

View File

@@ -0,0 +1,38 @@
Set.prototype.intersection ||= function <T>(set: Set<T>) {
const newSet = new Set();
for (const elm of this) {
if (set.has(elm)) {
newSet.add(elm);
}
}
return newSet;
};
Set.prototype.difference ||= function <T>(set: Set<T>) {
const newSet = new Set();
for (const elm of this) {
if (!set.has(elm)) {
newSet.add(elm);
}
}
return newSet;
};
Set.prototype.symmetricDifference ||= function <T>(set: Set<T>) {
const newSet = new Set();
for (const elm of this) {
if (!set.has(elm)) {
newSet.add(elm);
}
}
for (const elm of set) {
if (!this.has(elm)) {
newSet.add(elm);
}
}
return newSet;
};
Set.prototype.isDisjointFrom ||= function <T>(set: Set<T>) {
return this.symmetricDifference(set).size === 0;
};
Set.prototype.union ||= function <T>(set: Set<T>) {
return new Set([...this, ...set]);
};