@rian8337/osu-base 1.0.0 → 1.0.1
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 +62 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,11 +1,68 @@
|
|
|
1
|
-
#
|
|
1
|
+
# About
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The base module required for all my osu! modules.
|
|
4
4
|
|
|
5
|
-
|
|
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
|
-
|
|
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
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rian8337/osu-base",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Base module for all osu! related modules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"osu",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "8406e60764d46fc30483b95f56a097f2c0245417"
|
|
43
43
|
}
|