mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-22 09:35:37 -05:00
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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user