v0.1
This commit is contained in:
commit
4aaaf23d2f
2411 files changed
+1248679
No files matched your search
+26
@@ -0,0 +1,26 @@
|
||||
import { DoubleIndexedKV } from './double-indexed-kv.js';
|
||||
export class Registry {
|
||||
constructor(generateIdentifier) {
|
||||
this.generateIdentifier = generateIdentifier;
|
||||
this.kv = new DoubleIndexedKV();
|
||||
}
|
||||
register(value, identifier) {
|
||||
if (this.kv.getByValue(value)) {
|
||||
return;
|
||||
}
|
||||
if (!identifier) {
|
||||
identifier = this.generateIdentifier(value);
|
||||
}
|
||||
this.kv.set(identifier, value);
|
||||
}
|
||||
clear() {
|
||||
this.kv.clear();
|
||||
}
|
||||
getIdentifier(value) {
|
||||
return this.kv.getByValue(value);
|
||||
}
|
||||
getValue(identifier) {
|
||||
return this.kv.getByKey(identifier);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=registry.js.map
|
||||
Reference in new issue
Block a user