Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
L-Mario564 committed Feb 16, 2024
1 parent 9762b34 commit 7f437e0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
4 changes: 3 additions & 1 deletion docs/content/changelog.mdx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Changelog

## Unreleased
## 2.1.0

- Add `best_id` property to the `Score` interface.
- The `count_geki` and `count_katu` properties in the `ScoreStatistics` interface are now marked as nullable.
- Fix a bug with `getEnumMods` when passing NC and/or PF alongside other mods.
- Add `derivativeModsWithOriginal` parameter to `getModsEnum` in case the developer wishes for NC to output the same enum value as DTNC and for PF to output the same enum value as SDPF if set to `true`.

## 2.0.2

Expand Down
19 changes: 19 additions & 0 deletions docs/content/extras/mod-enum-conversion.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,22 @@ enumValue = getModsEnum(['HR', 'SD']); // Output: 48
enumValue = getModsEnum(['HR', 'SD', 'FL']); // Output: 1072
enumValue = getModsEnum(['DC']); // Output: 0, because DC (Daycore) is not present in the enum mentioned above
```

**Note:** In some responses, DT might be paired with NC and PF might paired with PF. DTNC and SDPF aren't possible mod combinations, but in the API, they are paired because NC derives from DT and PF derives from SD. So, if the API returns DTNC, it will be parsed as NC, and if it returns SDPF, it will parsed as PF.

```ts
let mods = getEnumMods(512); // Output: ['NC']
mods = getEnumMods(576); // DTNC is not a possible mod combo, so the output is: ['NC']
mods = getEnumMods(16384); // Output: ['PF']
mods = getEnumMods(16416); // SDPF is not a possible mod combo, so the output is: ['PF']
```

For the inverse operation, NC and PF will output their respective enum value (512 and 16384 respectively). If you have specific cases in which you want NC to output the enum value for DTNC, and PF to output the value for SDPF, then you can set `derivativeModsWithOriginal` to `true`.

```ts
let enumValue = getModsEnum(['NC']); // Output: 512
enumValue = getModsEnum(['PF']); // Output: 16384

enumValue = getModsEnum(['NC'], true); // Output: 576 (Same output for ['DT', 'NC'])
enumValue = getModsEnum(['PF'], true); // Output: 16416 (Same output for ['SD', 'PF'])
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "osu-web.js",
"version": "2.0.2",
"version": "2.1.0",
"description": "osu.js is an unofficial Javascript and Typescript SDK for the browser-facing portion of osu! with type safety in mind",
"main": "lib/index.cjs",
"module": "lib/index.js",
Expand Down

0 comments on commit 7f437e0

Please sign in to comment.