/osu-map

Parse an osu! map into a structured and type safe object.

Primary LanguageTypeScriptMIT LicenseMIT

@teages/osu-map

npm version npm downloads

Parse an osu! map into a structured and type safe object.

Usage

Install package:

# npm
npm install @teages/osu-map

# yarn
yarn add @teages/osu-map

# pnpm
pnpm install @teages/osu-map

# bun
bun install @teages/osu-map

Import:

// ESM
import { parseMap } from '@teages/osu-map'

// CommonJS
const { parseMap } = require('@teages/osu-map')

Use:

import { parseMap } from '@teages/osu-map'

const mapFile = useRawMap()
const map = parseMap(mapFile)
console.log(`Map: ${map.metadata.TitleUnicode} - ${map.metadata.ArtistUnicode} [${map.metadata.Version}]`)

// verify the first timing point
const firstTiming = map.timingPoints[0]
if (!firstTiming || firstTiming.type !== 'uninherited') {
  throw new Error('First timing point must be uninherited.')
}
console.log(`BPM of the first uninherited: ${firstTiming.BPM}`)

Development

  • Clone this repository
  • Install latest LTS version of Node.js
  • Enable Corepack using corepack enable
  • Install dependencies using pnpm install
  • Run interactive tests using pnpm dev

TODO

  • Add more storyboard things
  • Add stringifyMap function

License

Published under MIT License.

Special Thanks

Test maps from:

They are used for testing purposes only and not MIT licensed.