summaryrefslogtreecommitdiff
path: root/src/util.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.ts')
-rw-r--r--src/util.ts16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/util.ts b/src/util.ts
new file mode 100644
index 0000000..f6420b9
--- /dev/null
+++ b/src/util.ts
@@ -0,0 +1,16 @@
+export class MutableValue<T> {
+ private inner: T;
+
+ constructor(inner: T) {
+ this.inner = inner;
+ }
+
+ get value() {
+ return this.inner
+ }
+
+ public deriveNew(mutator: (self: T) => T): MutableValue<T> {
+ this.inner = mutator(this.inner);
+ return new MutableValue(this.inner);
+ }
+}