npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

osu-utils

v2.0.0

Published

Basics Utils for osu projects

Downloads

69

Readme

osu-utils

npm version Downloads

A comprehensive Node.js library for osu! development, providing tools for API integration, PP calculation, beatmap parsing, and various osu!-related utilities.

Features

  • Complete osu! API v1 Client - Full interface with automatic data formatting
  • Advanced PP Calculation - High-performance PP and difficulty calculations using rosu-pp-js
  • Multi-mode Support - Support for all osu! game modes (osu!, taiko, catch, mania)
  • Beatmap Parsing - Extract metadata and information from beatmap files
  • Utility Functions - Accuracy calculations, mod conversions, time formatting
  • Error Handling - Robust error handling with automatic retry and caching
  • Type Safety - Comprehensive parameter validation and type checking

Installation

npm install osu-utils

Quick Start

const { osuUtils, ApiV1 } = require('osu-utils');

// API Client
const api = new ApiV1('your-api-key');
const user = await api.getUser('Puparia');

// PP Calculation
const fs = require('fs');
const beatmapContent = fs.readFileSync('beatmap.osu', 'utf8');
const result = osuUtils.CalculatePP(beatmapContent, { combo: 200, misses: 0 });

console.log(`Star Rating: ${result.difficulty.stars}`);
console.log(`PP: ${result.performance.pp}`);

osu! API v1 Client

Complete interface for osu! API v1 with automatic data formatting and multi-mode support.

const { ApiV1 } = require('osu-utils');
const api = new ApiV1('your-api-key');

const user = await api.getUser('Puparia');
const bestScores = await api.getUserBest('Puparia', 0, 5);

Features: Auto-detection, structured responses, all game modes, error handling, retry logic, caching
Documentation: Data FormatsExamplesError Handling

Testing

Run the comprehensive test suite:

npm test

Run API-specific tests:

npm run test:api

Performance Points (PP) Calculation

osu-utils includes advanced PP and difficulty calculation capabilities!

This integration uses rosu-pp-js by @MaxOhn - a high-performance JavaScript binding to the Rust library rosu-pp through WebAssembly. This provides:

  • Ultra-fast calculations using WebAssembly
  • Industry-standard accuracy with rosu-pp algorithm
  • Full game mode support (osu!, taiko, catch, mania)
  • Advanced features like strain data and gradual calculations

PP Calculation Methods:

  • CalculatePP() - Complete difficulty + performance calculation
  • CalculateDifficulty() - Difficulty calculation only
  • GetStrains() - Strain data for difficulty visualization
  • ConvertBeatmap() - Convert beatmaps between game modes
  • GetBeatmapInfo() - Extract comprehensive beatmap metadata

Special thanks to @MaxOhn for creating the amazing rosu-pp-js library!

Usage Examples

API Client

const { ApiV1 } = require('osu-utils');
const api = new ApiV1('your-api-key');

// Get user information
const user = await api.getUser('Puparia');
console.log(`${user.username} is level ${user.stats.level}`);

// Get best scores with beatmap info
const bestScores = await api.getUserBest('Puparia', 0, 5, true);
bestScores.forEach(score => {
    console.log(`${score.beatmap.metadata.artist} - ${score.beatmap.metadata.title}`);
    console.log(`Score: ${score.score.toLocaleString()} - ${score.performance.accuracy}%`);
});

// Multi-mode support
const modes = [
    { name: 'osu!', id: 0 },
    { name: 'Taiko', id: 1 },
    { name: 'CTB', id: 2 },
    { name: 'Mania', id: 3 }
];

for (const mode of modes) {
    const user = await api.getUser('Puparia', mode.id);
    console.log(`${mode.name}: ${user.stats.pp} PP (#${user.stats.ppRank})`);
}

PP Calculation

const { osuUtils } = require('osu-utils');
const fs = require('fs');

// Read beatmap content
const beatmapContent = fs.readFileSync('beatmap.osu', 'utf8');

// Calculate PP for perfect score
const result = osuUtils.CalculatePP(beatmapContent, {
    combo: 200,
    misses: 0,
    mods: 0
});

console.log(`Star Rating: ${result.difficulty.stars}`);
console.log(`PP: ${result.performance.pp}`);

// Calculate PP with mods
const hrResult = osuUtils.CalculatePP(beatmapContent, {
    combo: 200,
    misses: 0,
    mods: 16 // Hard Rock
});

console.log(`PP with HR: ${hrResult.performance.pp}`);

// Calculate difficulty only (faster)
const difficulty = osuUtils.CalculateDifficulty(beatmapContent, {
    mods: 64 // Double Time
});

console.log(`Star Rating with DT: ${difficulty.stars}`);

Utility Functions

const { osuUtils } = require('osu-utils');

// Calculate accuracy
const accuracy = osuUtils.CalcAccuracy(0, 100, 50, 25, 5); // osu! mode
console.log(`Accuracy: ${accuracy}%`);

// Format time
const formatted = osuUtils.FormatMs(125000);
console.log(formatted); // "2:05.000"

// Convert mods
const bitmask = osuUtils.ModsStringToInt('HDHRDT');
console.log(bitmask); // 88

const modsString = osuUtils.ModsIntToString(88);
console.log(modsString); // "HDHRDT"

// Check mods
const hasHidden = osuUtils.HasMod(88, 'HD');
console.log(hasHidden); // true

Error Handling

try {
    const user = await api.getUser('Puparia');
    if (user === null) {
        console.log('User not found');
    } else {
        console.log('User found:', user.username);
    }
} catch (error) {
    console.error('API Error:', error.message);
}

Performance Features

  • Automatic Caching - API responses are cached for 5 minutes
  • Retry Logic - Automatic retry with exponential backoff for network errors
  • WebAssembly - PP calculations use WebAssembly for high performance
  • Memory Management - Beatmaps are automatically freed after calculations
  • Parameter Validation - Comprehensive input validation and error messages

Testing

The library includes a comprehensive test suite covering all functionality:

# Run all tests
npm test

# Run API-specific tests
npm run test:api

Test Coverage:

  • API Client (8 tests) - All endpoints and error handling
  • PP Calculation (4 tests) - All game modes and mods
  • Star Rating (3 tests) - Difficulty calculations
  • Beatmap Parsing (3 tests) - Metadata extraction
  • Utility Functions (4 tests) - Accuracy, time formatting, mods
  • Error Handling (2 tests) - Invalid inputs and network errors

Documentation

Requirements

  • Node.js 12.0.0 or higher
  • osu! API key (for API client functionality)

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

For questions, issues, or feature requests, please open an issue on GitHub.


Made with ❤️ for the osu! community