aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorVendicated <vendicated@riseup.net>2022-10-01 22:09:20 +0200
committerVendicated <vendicated@riseup.net>2022-10-01 22:09:20 +0200
commit2410582cf8f607990ce9e9b6b92360bba98f6a57 (patch)
tree672ddb30b1da5ed27c06862017bb4f51fee5d931 /src/utils
parentcac77dce406be92755519be595cf460e8f758b16 (diff)
downloadVencord-2410582cf8f607990ce9e9b6b92360bba98f6a57.tar.gz
Vencord-2410582cf8f607990ce9e9b6b92360bba98f6a57.tar.bz2
Vencord-2410582cf8f607990ce9e9b6b92360bba98f6a57.zip
Dedicated Updater Page, Settings feedback
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/ChangeList.ts24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/utils/ChangeList.ts b/src/utils/ChangeList.ts
new file mode 100644
index 0000000..d8f7449
--- /dev/null
+++ b/src/utils/ChangeList.ts
@@ -0,0 +1,24 @@
+export class ChangeList<T>{
+ private set = new Set<T>;
+
+ public get changeCount() {
+ return this.set.size;
+ }
+
+ public get hasChanges() {
+ return this.changeCount > 0;
+ }
+
+ public handleChange(item: T) {
+ if (!this.set.delete(item))
+ this.set.add(item);
+ }
+
+ public getChanges() {
+ return this.set.values();
+ }
+
+ public map<R>(mapper: (v: T, idx: number, arr: T[]) => R): R[] {
+ return [...this.getChanges()].map(mapper);
+ }
+}