typerinth
Version:
A TypeScript library for interacting with the Modrinth API.
40 lines (39 loc) • 1.04 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
class FacetGroup {
facets;
/**
* Creates a new FacetGroup with the given facets.
* Facets in a group are combined with an **OR** operation
* @param facets The facets to create the group with
*/
constructor(...facets) {
this.facets = facets;
}
/**
* Gets the facets
* @returns The facets
*/
getFacets() {
return this.facets;
}
/**
* Adds a facet to the group
* @param facet The facet to add
* @returns The facet group
*/
addFacet(facet) {
this.facets.push(facet);
return this;
}
/**
* Stringifies the facet group
* @returns The stringified facet group (e.g. ["categories:forge"] or ["version:1.16.5", "version:1.17.1"])
*/
stringify() {
if (this.facets.length === 0)
return "";
return "[" + this.facets.map(facet => facet.stringify()).join(", ") + "]";
}
}
exports.default = FacetGroup;