Refactor connection store (#5024)

* various clean ups

* formatting

* remove linting

* formatting

* IConfigurationService is even better

* messing with connection config tests

* update tests

* formatting

* foramtting

* remove unused code

* add more tests

* working through tests

* formatting

* more factoring of connection store and increase code coverage

* formatting

* fix tests

* change use of state service to storage service

* remove unused files

* fix strict null errors

* formatting
This commit is contained in:
Anthony Dresser
2019-04-30 13:32:32 -07:00
committed by GitHub
parent 44a2d009c0
commit 0f12d15020
19 changed files with 875 additions and 1016 deletions

View File

@@ -13,3 +13,52 @@ export function toObject<V>(map: Map<string, V>): { [key: string]: V } {
}
return {};
}
export class ReverseLookUpMap<K, V> {
private forward = new Map<K, V>();
private reverse = new Map<V, K>();
public clear(): void {
this.forward.clear();
this.reverse.clear();
}
public delete(key: K): boolean {
const reverseKey = this.forward.get(key);
if (key && reverseKey) {
return this.forward.delete(key) && this.reverse.delete(reverseKey);
} else {
return false;
}
}
public forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void {
this.forward.forEach(callbackfn, thisArg);
}
public get(key: K): V | undefined {
return this.forward.get(key);
}
public reverseGet(key: V): K | undefined {
return this.reverse.get(key);
}
public has(key: K): boolean {
return this.forward.has(key);
}
public reverseHas(key: V): boolean {
return this.reverse.has(key);
}
public set(key: K, value: V): ReverseLookUpMap<K, V> {
this.forward.set(key, value);
this.reverse.set(value, key);
return this;
}
public get size(): number {
return this.forward.size;
}
}