Do not add duplicate entries to description dictionary
This commit is contained in:
@@ -12,7 +12,8 @@ describe("description dictionary", () => {
|
||||
it("does not add duplicate entries", () => {
|
||||
const d = new DescriptionDictionary();
|
||||
d.add("ABC", new StringData("val1"));
|
||||
d.add("abc", new StringData("val2"));
|
||||
d.add("ABC", new StringData("val2"));
|
||||
d.add("abc", new StringData("val3"));
|
||||
|
||||
expect(d.pairs()).toEqual([{key: "ABC", value: new StringData("val1")}]);
|
||||
});
|
||||
|
||||
@@ -19,6 +19,11 @@ export class DescriptionDictionary extends Dictionary {
|
||||
}
|
||||
|
||||
override add(key: string, value: ExpressionData, description?: string): void {
|
||||
if (this.get(key) !== undefined) {
|
||||
// Key already added, ignore
|
||||
return;
|
||||
}
|
||||
|
||||
super.add(key, value);
|
||||
if (description) {
|
||||
this.descriptions.set(key, description);
|
||||
|
||||
Reference in New Issue
Block a user