poe-api-manager
Version:
poe.ninja and poe.watch API
46 lines (45 loc) • 1.59 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Utils = void 0;
const getLeagues_1 = __importDefault(require("./modules/utils/getLeagues"));
const propertyFilter_1 = __importDefault(require("./mainfunctions/propertyFilter"));
/**
* A utility class.
* @class
*/
class Utils {
constructor() { }
/**
* Fetches the list of leagues for the game.
* @returns {string[]} The array of league names.
* @throws {Error} If there's an error fetching the leagues.
*/
async getLeagues() {
try {
return await (0, getLeagues_1.default)();
}
catch (error) {
throw new Error(`Error fetching data Leagues: ${error.message}`);
}
}
/**
* Filters properties of objects in an array based on the specified properties.
*
* @param {object[]} data - The array of objects to filter.
* @param {string[]} properties - The array of property names to include in the result.
* @returns {Promise<object[]>} - An array of objects with only the specified properties.
* @throws {Error} If there's an error filtering the properties.
*/
async filterProperties(data, properties) {
try {
return (0, propertyFilter_1.default)(data, properties);
}
catch (error) {
throw new Error(`Error fetching data Leagues: ${error.message}`);
}
}
}
exports.Utils = Utils;