From: Lady <redacted>
Date: Mon, 29 May 2023 07:44:00 +0000 (-0700)
Subject: Return this on Tag add/delete methods
X-Git-Url: https://git.ladys.computer/Etiquette/commitdiff_plain/998a27ffd305bdbef26b0f864924660e575e6e44

Return this on Tag add/delete methods
---

diff --git a/model.js b/model.js
index 76bf615..6963a16 100644
--- a/model.js
+++ b/model.js
@@ -385,7 +385,10 @@ class Tag {
     });
   }
 
-  /** Adds the provided label(s) to this `Tag` as alternate labels. */
+  /**
+   * Adds the provided label(s) to this `Tag` as alternate labels, then
+   * returns this `Tag`.
+   */
   addAltLabel(...labels) {
     const altLabels = this.#data.altLabel;
     let objectLabels = null; // initialized on first use
@@ -428,11 +431,12 @@ class Tag {
         altLabels.add(literal);
       }
     }
+    return this;
   }
 
   /**
    * Adds the provided tags to the list of tags that this `Tag` is
-   * narrower than.
+   * narrower than, then returns this `Tag`.
    *
    * Arguments may be string identifiers or objects with an
    * `.identifier` property.
@@ -474,9 +478,13 @@ class Tag {
         }
       }
     }
+    return this;
   }
 
-  /** Adds the provided label(s) to this `Tag` as hidden labels. */
+  /**
+   * Adds the provided label(s) to this `Tag` as hidden labels, then
+   * returns this `Tag`.
+   */
   addHiddenLabel(...labels) {
     const hiddenLabels = this.#data.hiddenLabel;
     let objectLabels = null; // initialized on first use
@@ -519,11 +527,12 @@ class Tag {
         hiddenLabels.add(literal);
       }
     }
+    return this;
   }
 
   /**
    * Adds the provided tags to the list of tags that this `Tag` is in
-   * canon with.
+   * canon with, then returns this `Tag`.
    *
    * Arguments may be string identifiers or objects with an
    * `.identifier` property.
@@ -584,11 +593,12 @@ class Tag {
         }
       }
     }
+    return this;
   }
 
   /**
    * Adds the provided tags to the list of tags that this `Tag`
-   * involves.
+   * involves, then returns this `Tag`.
    *
    * Arguments may be string identifiers or objects with an
    * `.identifier` property.
@@ -650,6 +660,7 @@ class Tag {
         }
       }
     }
+    return this;
   }
 
   /** Yields the alternative labels of this `Tag`. */
@@ -726,7 +737,7 @@ class Tag {
 
   /**
    * Removes the provided string label(s) from this `Tag` as alternate
-   * labels.
+   * labels, then returns this `Tag`.
    */
   deleteAltLabel(...labels) {
     const altLabels = this.#data.altLabel;
@@ -761,11 +772,12 @@ class Tag {
         altLabels.delete(literal);
       }
     }
+    return this;
   }
 
   /**
    * Removes the provided tags from the list of tags that this `Tag` is
-   * narrower than.
+   * narrower than, then returns this `Tag`.
    *
    * Arguments may be string identifiers or objects with an
    * `.identifier` property.
@@ -776,11 +788,12 @@ class Tag {
       // Iterate over the provided tags and delete them.
       broader.delete(toIdentifier($));
     }
+    return this;
   }
 
   /**
    * Removes the provided string label(s) from this `Tag` as hidden
-   * labels.
+   * labels, then returns this `Tag`.
    */
   deleteHiddenLabel(...labels) {
     const hiddenLabels = this.#data.hiddenLabel;
@@ -815,11 +828,12 @@ class Tag {
         hiddenLabels.delete(literal);
       }
     }
+    return this;
   }
 
   /**
    * Removes the provided tags from the list of tags that this `Tag` is
-   * in canon with.
+   * in canon with, then returns this `Tag`.
    *
    * Arguments may be string identifiers or objects with an
    * `.identifier` property.
@@ -830,11 +844,12 @@ class Tag {
       // Iterate over the provided tags and delete them.
       inCanon.delete(toIdentifier($));
     }
+    return this;
   }
 
   /**
    * Removes the provided tags from the list of tags that this `Tag`
-   * involves.
+   * involves, then returns this `Tag`.
    *
    * Arguments may be string identifiers or objects with an
    * `.identifier` property.
@@ -845,6 +860,7 @@ class Tag {
       // Iterate over the provided tags and delete them.
       involves.delete(toIdentifier($));
     }
+    return this;
   }
 
   /** Yields `Tag`s that are in canon of this `Tag`. */
diff --git a/model.test.js b/model.test.js
index a648d4f..7190830 100644
--- a/model.test.js
+++ b/model.test.js
@@ -306,6 +306,11 @@ describe("TagSystem", () => {
           ],
         );
       });
+
+      it("[[Call]] returns this", () => {
+        const tag = new Tag();
+        assertStrictEquals(tag.addAltLabel(), tag);
+      });
     });
 
     describe("::addBroaderTag", () => {
@@ -328,6 +333,11 @@ describe("TagSystem", () => {
         );
       });
 
+      it("[[Call]] returns this", () => {
+        const tag = new Tag();
+        assertStrictEquals(tag.addBroaderTag(), tag);
+      });
+
       it("[[Call]] throws when adding a non‐persisted tag", () => {
         const tag = new Tag();
         assertThrows(() => {
@@ -372,6 +382,11 @@ describe("TagSystem", () => {
           ],
         );
       });
+
+      it("[[Call]] returns this", () => {
+        const tag = new Tag();
+        assertStrictEquals(tag.addHiddenLabel(), tag);
+      });
     });
 
     describe("::addInCanonTag", () => {
@@ -394,6 +409,11 @@ describe("TagSystem", () => {
         );
       });
 
+      it("[[Call]] returns this", () => {
+        const tag = new Tag("EntityTag");
+        assertStrictEquals(tag.addInCanonTag(), tag);
+      });
+
       it("[[Call]] throws when this is not a tag which can be placed in canon", () => {
         assertThrows(() => {
           new Tag().addInCanonTag();
@@ -447,6 +467,11 @@ describe("TagSystem", () => {
         );
       });
 
+      it("[[Call]] returns this", () => {
+        const tag = new Tag("ConceptualTag");
+        assertStrictEquals(tag.addInvolvesTag(), tag);
+      });
+
       it("[[Call]] throws when this is not a conceptual tag", () => {
         assertThrows(() => {
           new Tag().addInvolvesTag();
@@ -547,6 +572,11 @@ describe("TagSystem", () => {
         );
         assertEquals([...tag.altLabels()], ["four"]);
       });
+
+      it("[[Call]] returns this", () => {
+        const tag = new Tag();
+        assertStrictEquals(tag.deleteAltLabel(), tag);
+      });
     });
 
     describe("::deleteBroaderTag", () => {
@@ -579,6 +609,11 @@ describe("TagSystem", () => {
           [broader2.identifier],
         );
       });
+
+      it("[[Call]] returns this", () => {
+        const tag = new Tag();
+        assertStrictEquals(tag.deleteBroaderTag(), tag);
+      });
     });
 
     describe("::deleteHiddenLabel", () => {
@@ -605,6 +640,11 @@ describe("TagSystem", () => {
         );
         assertEquals([...tag.hiddenLabels()], ["four"]);
       });
+
+      it("[[Call]] returns this", () => {
+        const tag = new Tag();
+        assertStrictEquals(tag.deleteHiddenLabel(), tag);
+      });
     });
 
     describe("::deleteInCanonTag", () => {
@@ -633,6 +673,11 @@ describe("TagSystem", () => {
           [canon2.identifier],
         );
       });
+
+      it("[[Call]] returns this", () => {
+        const tag = new Tag("EntityTag");
+        assertStrictEquals(tag.deleteInCanonTag(), tag);
+      });
     });
 
     describe("::deleteInvolvesTag", () => {
@@ -665,6 +710,11 @@ describe("TagSystem", () => {
           [involved2.identifier],
         );
       });
+
+      it("[[Call]] returns this", () => {
+        const tag = new Tag("ConceptualTag");
+        assertStrictEquals(tag.deleteInvolvesTag(), tag);
+      });
     });
 
     describe("::hasInCanonTags", () => {