]> Lady’s Gitweb - Etiquette/blobdiff - model.js
Return undefined not null when resolving fails
[Etiquette] / model.js
index d64f6c4218889f7cab3c60dbc215fec884fe6ead..cfd228d88f12e7e7625a1f2374f3775d57021683 100644 (file)
--- a/model.js
+++ b/model.js
@@ -901,7 +901,7 @@ const {
        * of the `TagSystem` associated with this constructor.
        *
        * ※ If the I·R·I is not recognized, this function returns
-       * `null`.
+       * `undefined`.
        */
       fromIRI(iri) {
         const system = this.#system;
@@ -919,10 +919,12 @@ const {
           try {
             // Attempt to resolve the identifier.
             const instance = storage.get(identifier);
-            return Tag.getSystem(instance) == system ? instance : null;
+            return Tag.getSystem(instance) == system
+              ? instance
+              : undefined;
           } catch {
             // Do not throw for bad identifiers.
-            return null;
+            return undefined;
           }
         }
       }
@@ -933,13 +935,15 @@ const {
        * ☡ This function throws if the identifier is invalid.
        *
        * ※ If the identifier is valid but not recognized, this
-       * function returns `null`.
+       * function returns `undefined`.
        */
       fromIdentifier(identifier) {
         const system = this.#system;
         const storage = this.#storage;
         const instance = storage.get(identifier);
-        return Tag.getSystem(instance) == system ? instance : null;
+        return Tag.getSystem(instance) == system
+          ? instance
+          : undefined;
       }
 
       /**
@@ -949,7 +953,7 @@ const {
        * match the tagging entity of this constructor’s `TagSystem`.
        *
        * ※ If the specific component of the Tag U·R·I is not
-       * recognized, this function returns `null`.
+       * recognized, this function returns `undefined`.
        */
       fromTagURI(tagURI) {
         const system = this.#system;
@@ -967,10 +971,12 @@ const {
           try {
             // Attempt to resolve the identifier.
             const instance = storage.get(identifier);
-            return Tag.getSystem(instance) == system ? instance : null;
+            return Tag.getSystem(instance) == system
+              ? instance
+              : undefined;
           } catch {
             // Do not throw for bad identifiers.
-            return null;
+            return undefined;
           }
         }
       }
This page took 0.024977 seconds and 4 git commands to generate.