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

oppai

v0.1.19

Published

pp v2 and difficulty calculator for osu!

Readme

Node bindings for oppai, a ppv2 and difficulty calculator for osu!.

Tested on node v7.0.0 on linux, should work on windows as long as you have a compiler that npm can use. At some point I'll include pre-built windows binaries.

Installing

mkdir myproject
cd myproject
npm install oppai
# write your index.js

If you're on windows, you might need to set up build tools:

npm install --global --production windows-build-tools

If you get compilation errors, try updating node to at least the latest LTS version (I use 7.0.0).

If it's still broken, hit me up on github issues and specify your operating system, node -v and full output of npm install oppai.

Usage

Here's a rather minimal example that parses a beatmap and calculates difficulty and pp.

You can find full documentation here: Markdown Documentation.

const path = require('path');
const util = require('util');
const oppai = require('oppai');

function main()
{
    process.argv.splice(0, 1);

    if (process.argv.length != 2)
    {
        console.error("Usage: " + process.argv[0] + " file.osu");
        process.exit(1);
    }

    var script_path = path.dirname(process.argv[0]);

    // if you need to multithread, create one ctx and buffer for each thread
    var ctx = oppai.Ctx();

    // parse beatmap -----------------------------------------------------------
    var b = oppai.Beatmap(ctx);

    const BUFSIZE = 2000000; // should be big enough to hold the .osu file
    var buf = oppai.Buffer(BUFSIZE);

    b.parse(
        process.argv[1],
        buf,
        BUFSIZE,

        // don't disable caching and use js script's folder for caching
        false,
        script_path
    );

    console.log("Cache folder: " + script_path + "\n");

    console.log(
        util.format(
            "%s - %s [%s] (by %s)\n" +
            "CS%d OD%d AR%d HP%d\n" +
            "%d objects (%d circles, %d sliders, %d spinners)\n" +
            "max combo: %d",
            b.artist(), b.title(), b.version(), b.creator(),
            b.cs().toPrecision(2), b.od().toPrecision(2),
            b.ar().toPrecision(2), b.hp().toPrecision(2),
            b.numObjects(), b.numCircles(), b.numSliders(), b.numSpinners(),
            b.maxCombo()
        )
    );

    // diff calc ---------------------------------------------------------------
    dctx = oppai.DiffCalcCtx(ctx);
    diff = dctx.diffCalc(b);

    console.log(
        util.format(
            "\n%d stars\n%d aim stars\n%d speed stars",
            diff.stars, diff.aim, diff.speed
        )
    )

    // pp calc -----------------------------------------------------------------
    res = ctx.ppCalc(diff.aim, diff.speed, b);

    console.log(
        util.format(
            "\n%d aim\n%d speed\n%d acc\n%d pp\nfor %d%%",
            res.aimPp, res.speedPp, res.accPp, res.pp, res.accPercent
        )
    );
}

main();