* generating the value of `TagSystem::Tag`. It isn’t possible to
* access this function in its unbound form from outside this module.
*
+ * ☡ This function throws if the I·R·I is not in the `.iriSpace` of
+ * the `TagSystem` associated with this constructor.
+ *
* ※ If the I·R·I is not recognized, this function returns `null`.
*/
static fromIRI(system, storage, iri) {
const name = `${iri}`;
- const prefix =
- `https://${system.authorityName}/tag:${system.taggingEntity}:`;
+ const prefix = `${system.iriSpace}`;
if (!name.startsWith(prefix)) {
// The I·R·I does not begin with the expected prefix.
- return null;
+ throw new RangeError(
+ `I·R·I did not begin with the expected prefix: ${iri}`,
+ );
} else {
// The I·R·I begins with the expected prefix.
const identifier = name.substring(prefix.length);
if (!tagName.startsWith(tagPrefix)) {
// The Tag U·R·I does not begin with the expected prefix.
throw new RangeError(
- `Tag U·R·I did not begin with the expected prefix: ${tagName}`,
+ `Tag U·R·I did not begin with the expected prefix: ${tagURI}`,
);
} else {
// The I·R·I begins with the expected prefix.
});
}
- /** 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
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.
}
}
}
+ 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
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.
}
}
}
+ 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.
}
}
}
+ return this;
}
/** Yields the alternative labels of this `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;
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.
// 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;
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.
// 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.
// Iterate over the provided tags and delete them.
involves.delete(toIdentifier($));
}
+ return this;
}
/** Yields `Tag`s that are in canon of this `Tag`. */
/** Returns the I·R·I for this `Tag`. */
get iri() {
- const tagURI = this.tagURI;
- return tagURI == null
- ? null
- : `https://${this.authorityName}/${tagURI}`;
+ const { identifier, iriSpace } = this;
+ return identifier == null ? null : `${iriSpace}${identifier}`;
+ }
+
+ /** Returns the I·R·I space for this `Tag`. */
+ get iriSpace() {
+ return this.#system.iriSpace;
}
/** Returns the kind of this `Tag`. */
/** Returns the I·R·I for this `TagSystem`. */
get iri() {
- return `https://${this.authorityName}/${this.tagURI}`;
+ return `${this.iriSpace}${this.identifier}`;
+ }
+
+ /**
+ * Returns the prefix used for I·R·I’s of `Tag`s in this `TagSystem`.
+ */
+ get iriSpace() {
+ return `https://${this.authorityName}/tag:${this.taggingEntity}:`;
}
/** Returns the Tag U·R·I for this `TagSystem`. */