UNPKG

osu-api-extended

Version:

Advanced osu! api wrapper cover all V2 and V1 endpoints, and provide useful tools

68 lines (67 loc) 1.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.country_details = void 0; const enums_1 = require("../types/enums"); const handleErrors_1 = require("../utility/handleErrors"); /** * Get more information about the country by providing an name/code. * *   * * ### Parameters * - `name` - Name of the country or country code * *   * * ### Usage Example * ```js * const { tools } = require('osu-api-extended'); * * function main() { * try { * const result = tools.country_details('US'); * // or * const result = tools.country_details('United States'); * if (result.error != null) { * console.log(result.error); * return; * }; * * * console.log(result); * } catch (error) { * console.log(error); * }; * }; * * main(); * ``` */ const country_details = (name) => { if (name == null || name == '') { return (0, handleErrors_1.handleErrors)(new Error('Specify country code or country name')); } ; if (name.length == 2) { const find = enums_1.CountryNames[name.toUpperCase()]; if (find == null) { return (0, handleErrors_1.handleErrors)(new Error('Country not found')); } ; return { code: name.toUpperCase(), name: find, }; } ; const find = enums_1.CountryCodes[name]; if (find == null) { return (0, handleErrors_1.handleErrors)(new Error('Country not found')); } ; return { code: name, name: find, }; }; exports.country_details = country_details;