UNPKG

typerinth

Version:

A TypeScript library for interacting with the Modrinth API.

40 lines (39 loc) 1.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); class SearchFacets { facetGroups; /** * Creates an array of FacetGroups for searching. * FacetGroups are combined with an **AND** operation * @param facetGroups */ constructor(...facetGroups) { this.facetGroups = facetGroups; } /** * Gets the facet groups * @returns The facet groups */ getFacetGroups() { return this.facetGroups; } /** * Adds a facet group to the search * @param facetGroup The facet group to add * @returns The search facets */ addFacetGroup(facetGroup) { this.facetGroups.push(facetGroup); return this; } /** * Stringifies the search facets * @returns The stringified search facets (e.g. [["categories:forge"], ["version:1.16.5", "version:1.17.1"]]) */ stringify() { if (this.facetGroups.length === 0) return ""; return "[" + this.facetGroups.map(facetGroup => facetGroup.stringify()).join(", ") + "]"; } } exports.default = SearchFacets;