diff --git a/nullboard.html b/nullboard.html
index c84937b..b652c8a 100644
--- a/nullboard.html
+++ b/nullboard.html
@@ -1237,6 +1237,52 @@
}
}
+ class NamespacedDatabase extends Database {
+ constructor(namespace, database)
+ {
+ super();
+ this.database = database
+ this.namespace = namespace;
+ }
+
+ deprefix(key)
+ {
+ if (key.startsWith(this.namespace + "."))
+ return key.slice(this.namespace.length + 1);
+ return key;
+ }
+
+ prefix(key)
+ {
+ return this.namespace + "." + key;
+ }
+
+ get(key) {
+ var k = this.prefix(key);
+ return this.database.get(k);
+ }
+
+ set(key, value)
+ {
+ var k = this.prefix(key);
+ return this.database.set(k, value);
+ }
+
+ del(key)
+ {
+ var k = this.prefix(key);
+ return this.database.del(k);
+ }
+
+ forEach(foo)
+ {
+ this.database.forEach((key) => {
+ var k = this.deprefix(key);
+ foo(k);
+ });
+ }
+ }
+
class Local extends Database {
constructor()
{
@@ -1275,7 +1321,7 @@
}
}
- globalStorage = new Local();
+ globalStorage = new NamespacedDatabase("4", new Local());
/*
* poor man's error handling -- $fixme