UNPKG

enkanetwork

Version:

API wrapper for enka.network written on TypeScript which provides localization, caching and convenience

30 lines (29 loc) 1.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CostumeFinder = void 0; const errors_1 = require("../../errors"); class CostumeFinder { data; localization; constructor(data, localization) { this.data = data; this.localization = localization; } // Searching for a **costume** by his ID getById(id) { const costume = this.data.find((costume) => costume.id === id); if (!costume) throw new errors_1.NoDataAssetsFound(`There is no costume with id = ${id}! (check the actuality of assets)`); return costume; } getName(costume, language) { const nameLocalizations = this.localization[costume.nameTextMapHash]; if (!nameLocalizations) throw new errors_1.NoLocalizationAssetsFound(`There is no localization for costume with id = ${costume.id}! (check the actuality of assets)`); const name = nameLocalizations[language]; if (!name) throw new errors_1.NoLanguageFound("This language is not downloaded! Check the AssetsUpdater settings"); return name; } } exports.CostumeFinder = CostumeFinder;