typerinth
Version:
A TypeScript library for interacting with the Modrinth API.
66 lines (65 loc) • 1.73 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Represents a facet
*
* A facet is a filter for searching
* It consists of a type, an operation, and a value
* @example
* // Facet where the version is "1.16.5"
* new Facet(FacetType.Versions, FacetOperation.EQUALS, "1.16.5")
* @example
* // Facet where the downloads are greater than 1000
* new Facet(FacetType.Downloads, FacetOperation.GREATER_THAN, "1000")
*/
class Facet {
type;
operation;
value;
/**
* Creates a new Facet
* @param type The type of the facet
* @param operation The operation of the facet
* @param value The value of the facet
* @example
* // Facet where the version is "1.16.5"
* new Facet(FacetType.Versions, FacetOperation.EQUALS, "1.16.5")
* @example
* // Facet where the downloads are greater than 1000
* new Facet(FacetType.Downloads, FacetOperation.GREATER_THAN, "1000")
*/
constructor(type, operation, value) {
this.type = type;
this.operation = operation;
this.value = value;
}
/**
* Gets the type of the facet
* @returns The type of the facet
*/
getType() {
return this.type;
}
/**
* Gets the operation of the facet
* @returns The operation of the facet
*/
getOperation() {
return this.operation;
}
/**
* Gets the value of the facet
* @returns The value of the facet
*/
getValue() {
return this.value;
}
/**
* Stringifies the facet
* @returns The stringified facet
*/
stringify() {
return `"${this.type}${this.operation}${this.value}"`;
}
}
exports.default = Facet;