UNPKG

nodesu

Version:
142 lines (114 loc) 7.15 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Source: components/BeatmapsComponent.js</title> <script src="scripts/prettify/prettify.js"> </script> <script src="scripts/prettify/lang-css.js"> </script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <div id="main"> <h1 class="page-title">Source: components/BeatmapsComponent.js</h1> <section> <article> <pre class="prettyprint source linenums"><code>'use strict'; const Component = require('./Component') , ApiConstants = require('../Constants').API , Beatmap = require('../struct/Beatmap') , Mods = require('../enum/Mods'); /** * Beatmap-related API component * @memberof module:Components * @example * api.beatmaps * .getByBeatmapId('646609') * .then(console.log); */ class BeatmapsComponent extends Component { _get(letter, id, mode, limit, includeConverts, lookupType, mods) { let options = {}; options[letter] = id; if (mode !== undefined) options.m = mode; if (limit !== undefined) options.limit = limit; if (includeConverts !== undefined) options.a = includeConverts; if (lookupType !== undefined) options.type = lookupType; // Include mods and filter out mods that return null difficulty values if (mods !== undefined) options.mods = mods &amp; (Mods.DoubleTime | Mods.Easy | Mods.HalfTime | Mods.HardRock | Mods.Key4 | Mods.Key5 | Mods.Key6 | Mods.Key7 | Mods.Key8 | Mods.Key9); return this.api.requester.get(ApiConstants.BEATMAPS_GET, options, true, true, Beatmap); } /** * Get beatmaps via beatmap set ID. * @param {String} setId The set ID to lookup beatmaps from. * @param {Mode} [mode] The gamemode of maps to find. * @param {Number} [limit] The limit of maps to find. * @param {Converts} [includeConverts] If converts should be included in the lookup. * @param {Mods} [mods] Applied mods. * @return {Promise&lt;Object[]|Beatmap[]>} The object array from the API, or Beatmap object array if parsing is enabled. */ getBySetId(setId, mode, limit, includeConverts, mods) { return this._get('s', setId, mode, limit, includeConverts, undefined, mods); } /** * Get beatmaps via beatmap ID. * @param {String} beatmapId The beatmap ID to lookup beatmaps from. * @param {Mode} [mode] The gamemode of maps to find. * @param {Number} [limit] The limit of maps to find. * @param {Converts} [includeConverts] If converts should be included in the lookup. * @param {Mods} [mods] Applied mods. * @return {Promise&lt;Object[]|Beatmap[]>} The object array from the API, or Beatmap object array if parsing is enabled. */ getByBeatmapId(beatmapId, mode, limit, includeConverts, mods) { return this._get('b', beatmapId, mode, limit, includeConverts, undefined, mods); } /** * Get beatmaps via user ID. * @param {String} user The user to lookup beatmaps from. * @param {Mode} [mode] The gamemode of maps to find. * @param {Number} [limit] The limit of maps to find. * @param {Converts} [includeConverts] If converts should be included in the lookup. * @param {LookupType} [lookupType] The type of lookup of the user. * @param {Mods} [mods] Applied mods. * @return {Promise&lt;Object[]|Beatmap[]>} The object array from the API, or Beatmap object array if parsing is enabled. */ getByUser(user, mode, limit, includeConverts, lookupType, mods) { return this._get('u', user, mode, limit, includeConverts, lookupType, mods); } /** * Get beatmaps via the hash of a beatmap. * @param {String} hash The hash of the beatmap to lookup. * @param {Mode} [mode] The gamemode of maps to find. * @param {Number} [limit] The limit of maps to find. * @param {Converts} [includeConverts] If converts should be included in the lookup. * @param {Mods} [mods] Applied mods. * @return {Promise&lt;Object[]|Beatmap[]>} The object array from the API, or Beatmap object array if parsing is enabled. */ getByBeatmapHash(hash, mode, limit, includeConverts, mods) { return this._get('h', hash, mode, limit, includeConverts, undefined, mods); } } module.exports = BeatmapsComponent;</code></pre> </article> </section> </div> <nav> <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Components.html">Components</a></li><li><a href="module-CustomClasses.html">CustomClasses</a></li><li><a href="module-Enums.html">Enums</a></li><li><a href="module-Errors.html">Errors</a></li></ul><h3>Classes</h3><ul><li><a href="Client.html">Client</a></li><li><a href="module-Components.BeatmapsComponent.html">BeatmapsComponent</a></li><li><a href="module-Components.MultiComponent.html">MultiComponent</a></li><li><a href="module-Components.ReplayComponent.html">ReplayComponent</a></li><li><a href="module-Components.ScoresComponent.html">ScoresComponent</a></li><li><a href="module-Components.UserComponent.html">UserComponent</a></li><li><a href="module-CustomClasses.Beatmap.html">Beatmap</a></li><li><a href="module-CustomClasses.BeatmapScore.html">BeatmapScore</a></li><li><a href="module-CustomClasses.Multi.html">Multi</a></li><li><a href="module-CustomClasses.MultiGame.html">MultiGame</a></li><li><a href="module-CustomClasses.MultiMatch.html">MultiMatch</a></li><li><a href="module-CustomClasses.MultiScore.html">MultiScore</a></li><li><a href="module-CustomClasses.ReplayData.html">ReplayData</a></li><li><a href="module-CustomClasses.Score.html">Score</a></li><li><a href="module-CustomClasses.User.html">User</a></li><li><a href="module-CustomClasses.UserEvent.html">UserEvent</a></li><li><a href="module-CustomClasses.UserScore.html">UserScore</a></li><li><a href="module-Errors.OsuApiError.html">OsuApiError</a></li><li><a href="Requester.html">Requester</a></li></ul><h3>Global</h3><ul><li><a href="global.html#ApprovalStatus">ApprovalStatus</a></li><li><a href="global.html#Converts">Converts</a></li><li><a href="global.html#Genre">Genre</a></li><li><a href="global.html#Language">Language</a></li><li><a href="global.html#LookupType">LookupType</a></li><li><a href="global.html#Mode">Mode</a></li><li><a href="global.html#Mods">Mods</a></li><li><a href="global.html#MultiScoringType">MultiScoringType</a></li><li><a href="global.html#MultiTeam">MultiTeam</a></li><li><a href="global.html#MultiTeamType">MultiTeamType</a></li></ul> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a> on Sat Apr 11 2020 14:41:31 GMT+1000 (GMT+10:00) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>