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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@smwcentral/bps

v1.0.1

Published

Library for patching BPS files, focusing on games supported by SMW Central

Readme

SMW Central BPS patching library

Latest Stable Version License

The JavaScript BPS patching library used by SMW Central, most notably for its Online Tools section.

Installation

NodeJS

Install from NPM using your favorite package manager:

$ npm install @smwcentral/bps
$ pnpm add @smwcentral/bps
$ yarn add @smwcentral/bps

You can then import the library as an ES module:

import * as bps from "@smwcentral/bps";

TypeScript declarations are built in.

Browser (CDN)

You can import the module directly from a CDN:

<script type="module">
    import * as bps from "https://cdn.jsdelivr.net/npm/@smwcentral/[email protected]/dist/index.js";
</script>

For convenience, use an import map:

<script type="importmap">
    {
        "imports": {
            "@smwcentral/bps": "https://cdn.jsdelivr.net/npm/@smwcentral/[email protected]/dist/index.js"
        }
    }
</script>

<script type="module">
    import * as bps from "@smwcentral/bps";
</script>

Usage

Apply BPS patch

The applyBPS function directly applies a BPS patch, with the base file and patch represented as a Uint8Array or equivalent.

import {readFileSync, writeFileSync} from "node:fs";
import {applyBPS} from "@smwcentral/bps";

const base = readFileSync("base.bin");
const patch = readFileSync("patch.bps");

const result = applyBPS(base, patch);

writeFileSync("result.bin", result);

If patching fails, PatchError will be thrown:

  • MalformedPatchError: The patch is not a BPS patch
  • WrongInputSizeError: The input file has a wrong size
  • WrongInputChecksumError: The input file has a wrong checksum

Apply BPS patch adaptively

The adaptiveApplyBPS function applies a BPS patch and attempts to make adaptations to the input file. The optional 3rd arguments allows you to tweak which adaptations are enabled (by default, everything is enabled).

import {readFileSync, writeFileSync} from "node:fs";
import {adaptiveApplyBPS} from "@smwcentral/bps";

const base = readFileSync("base.bin");
const patch = readFileSync("patch.bps");

const result = adaptiveApplyBPS(base, patch, {
    trySMC: true,
    trySMB2: true,
});

writeFileSync("result.bin", result);

The following adaptations are currently supported:

  • trySMC: If enabled, a patch made for a headerless SNES ROM (.sfc) can be applied to a headered input ROM (.smc). In this case, the result will be a headered ROM (.smc). Note that patches generated by Flips (such as most BPS patches on SMW Central) are typically based on a headerless ROM, even if the original base ROM was headered.
  • trySMB2: If enabled, patches made for Super Mario Bros. 2 can be applied to any commonly used ROM (Rev 0, Rev 0 in NES 2.0 format, and Rev A), no matter the combination of patch and input ROM.

Tests

Complete tests are available in the tests directory. Run with:

$ npm test

Some tests require commercial ROM files to be available in order to run. These tests will be skipped by default. In order to run the full test suite, you need to supply the following the ROM files, which are presumably personal backups of the copies of the respective games that you already own:

47ba60fad332fdea5ae44b7979fe1ee78de1d316ee027fea2ad5fe3c0d86f25a  Super Mario Bros. 2 (U) (PRG0) [!].nes
41300bc4942a8a4f9b53148b404dd5cae3dd708ebdd9b617888d290a51a83e43  Super Mario Bros. 2 (USA).nes
6ca47e9da206914730895e45fef4f7393e59772c1c80e9b9befc1a01d7ecf724  Super Mario Bros. 2 (USA) (Rev A).nes
0838e531fe22c077528febe14cb3ff7c492f1f5fa8de354192bdff7137c27f5b  Super Mario World (U) [!].sfc
d70c9c7716ad12c674fc7dd744736aa48d4d7b4237f58066be620fda26024872  Super Mario World (U) [!].smc

Place any ROMs you have in the tests/roms directory with exactly the filenames listed above. The test suite will automatically detect the ROMs, validate their checksum, and enable any tests that use them.

License

Released under the MIT License.

Credits

Built and maintained by Telinc1. Original JavaScript BPS patcher by Sir_Walrus. SMC support by trillian. Super Mario Bros. 2 support by CircleFriendo.