Connection Store Refactor (#4632)

* 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
This commit is contained in:
Anthony Dresser
2019-03-22 01:07:32 -07:00
committed by GitHub
parent 5f637036bc
commit 756f77063a
19 changed files with 896 additions and 1007 deletions

View File

@@ -15,3 +15,48 @@ 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 {
let reverseKey = this.forward.get(key);
return this.forward.delete(key) && this.reverse.delete(reverseKey);
}
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 {
return this.forward.get(key);
}
public reverseGet(key: V): K {
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;
}
}