@rian8337/osu-base 1.0.0 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,11 +1,68 @@
1
- # `osu-base`
1
+ # About
2
2
 
3
- > TODO: description
3
+ The base module required for all my osu! modules.
4
4
 
5
- ## Usage
5
+ # Features
6
6
 
7
+ This module provides the required feature for all my osu! related modules, which is the beatmap parser.
8
+
9
+ # Specific Requirements
10
+
11
+ If you want to retrieve a beatmap using osu! API, you need to have an osu! API key set as `OSU_API_KEY` environment variable.
12
+
13
+ See usage for more details.
14
+
15
+ # Installation
16
+
17
+ ```
18
+ npm i @rian8337/osu-base
7
19
  ```
8
- const osuBase = require('osu-base');
9
20
 
10
- // TODO: DEMONSTRATE API
21
+ or
22
+
23
+ ```
24
+ yarn add @rian8337/osu-base
25
+ ```
26
+
27
+ # Usage
28
+
29
+ ## Using osu! API
30
+
31
+ ```js
32
+ import { MapInfo } from "@rian8337/osu-base";
33
+
34
+ // MD5 hash is also supported, but when both options are specified, beatmap ID is used
35
+ const beatmapInfo = await MapInfo.getInformation({
36
+ beatmapID: 901854,
37
+ hash: "hash123",
38
+ file: true,
39
+ });
40
+
41
+ if (!beatmapInfo.title) {
42
+ return console.log("Beatmap not found");
43
+ }
44
+
45
+ // Parsed beatmap can be accessed via the `map` field
46
+ // Note that the parsed beatmap will be cloned every time this is called. This allows caching of the original instance when needed
47
+ console.log(beatmapInfo.map);
48
+ ```
49
+
50
+ ### Not retrieving beatmap file
51
+
52
+ You can also opt out from downloading the beatmap (`.osu`) file if you just want to retrieve information from the API by setting `file` to `false`, however a parsed beatmap will not be provided.
53
+
54
+ ## Using without osu! API
55
+
56
+ ```js
57
+ import { readFile } from "fs";
58
+ import { Parser } from "@rian8337/osu-base";
59
+
60
+ readFile("path/to/file.osu", { encoding: "utf-8" }, (err, data) => {
61
+ if (err) throw err;
62
+
63
+ const parser = new Parser().parse(data);
64
+
65
+ // Parsed beatmap can be accessed via the `map` field
66
+ console.log(parser.map);
67
+ });
11
68
  ```
@@ -192,13 +192,8 @@ class MapStats {
192
192
  * @param statisticsMultiplier The statistics multiplier to calculate from map-changing nonspeed-changing mods.
193
193
  */
194
194
  static modifyOD(baseOD, speedMultiplier, statisticsMultiplier) {
195
- let od = baseOD;
196
- od *= statisticsMultiplier;
197
- let odMS = this.OD0_MS - Math.ceil(this.OD_MS_STEP * od);
198
- odMS = Math.min(this.OD0_MS, Math.max(this.OD10_MS, odMS));
199
- odMS /= speedMultiplier;
200
- od = (this.OD0_MS - odMS) / this.OD_MS_STEP;
201
- return od;
195
+ const hitWindowGreat = new HitWindow_1.OsuHitWindow(Math.min(10, baseOD * statisticsMultiplier)).hitWindowFor300() / speedMultiplier;
196
+ return (this.OD0_MS - hitWindowGreat) / this.OD_MS_STEP;
202
197
  }
203
198
  }
204
199
  exports.MapStats = MapStats;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rian8337/osu-base",
3
- "version": "1.0.0",
3
+ "version": "1.0.5",
4
4
  "description": "Base module for all osu! related modules.",
5
5
  "keywords": [
6
6
  "osu",
@@ -17,6 +17,8 @@
17
17
  ],
18
18
  "scripts": {
19
19
  "build": "tsc",
20
+ "generate-docs": "typedoc src/index.ts",
21
+ "lint": "eslint --ext ts",
20
22
  "prepare": "npm run build",
21
23
  "test": "jest -i"
22
24
  },
@@ -39,5 +41,5 @@
39
41
  "publishConfig": {
40
42
  "access": "public"
41
43
  },
42
- "gitHead": "e4fdb9c1ed6f90e70651c1aedfdb964b61cb240d"
44
+ "gitHead": "c8c092485a5ae3be16f2bfa0a3defb00163918d7"
43
45
  }
@@ -141,9 +141,9 @@ declare module "@rian8337/osu-base" {
141
141
  get maxCombo(): number;
142
142
  /**
143
143
  * Returns a time combined with beatmap-wide time offset.
144
- *
144
+ *
145
145
  * BeatmapVersion 4 and lower had an incorrect offset. Stable has this set as 24ms off.
146
- *
146
+ *
147
147
  * @param time The time.
148
148
  */
149
149
  getOffsetTime(time: number): number;
@@ -165,7 +165,10 @@ declare module "@rian8337/osu-base" {
165
165
  * @param time The time.
166
166
  * @param list The timing points to search in.
167
167
  */
168
- private getTimingPoint<T extends TimingPoint>(time: number, list: T[]): T;
168
+ private getTimingPoint<T extends TimingPoint>(
169
+ time: number,
170
+ list: T[]
171
+ ): T;
169
172
  /**
170
173
  * Returns a string representative of the class.
171
174
  */
@@ -265,7 +268,7 @@ declare module "@rian8337/osu-base" {
265
268
  /**
266
269
  * Represents the headcircle of a slider (sliderhead).
267
270
  */
268
- export class HeadCircle extends Circle { }
271
+ export class HeadCircle extends Circle {}
269
272
 
270
273
  /**
271
274
  * Represents a hitobject in a beatmap.
@@ -643,7 +646,7 @@ declare module "@rian8337/osu-base" {
643
646
  });
644
647
  /**
645
648
  * Calculates map statistics.
646
- *
649
+ *
647
650
  * This can only be called once for an instance.
648
651
  */
649
652
  calculate(params?: {
@@ -1564,7 +1567,7 @@ declare module "@rian8337/osu-base" {
1564
1567
  /**
1565
1568
  * Represents the tailcircle of a slider (sliderend).
1566
1569
  */
1567
- export class TailCircle extends Circle { }
1570
+ export class TailCircle extends Circle {}
1568
1571
 
1569
1572
  /**
1570
1573
  * Represents a timing point that changes the beatmap's BPM.
@@ -1882,7 +1885,7 @@ declare module "@rian8337/osu-base" {
1882
1885
  buildURL(): string;
1883
1886
  /**
1884
1887
  * Sends a request to the API using built parameters.
1885
- *
1888
+ *
1886
1889
  * If the request fails, it will be redone 5 times.
1887
1890
  */
1888
1891
  sendRequest(): Promise<RequestResponse>;