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

rm2k-wasm

v1.0.0

Published

WASM bindings for rm2k-lib: reads and writes the RPG Maker 2000/2003 LCF binary formats.

Readme

rm2k-wasm

WebAssembly bindings for rm2k-lib, which reads and writes the RPG Maker 2000/2003 LCF binary formats, generated via wasm-bindgen.

The domain model (Database, Map, Save, TreeMap and everything nested under them) is close to a hundred structs, so it is not individually wrapped. Instead, loaded values cross the JS boundary as plain JavaScript values via serde-wasm-bindgen, reusing rm2k-lib's own serde feature. value is therefore untyped (any) on the TypeScript side by design - treat it as the same object shape you'd get from rm2k's own serde_json output, documented in the root crate's README.

Install

npm install rm2k-wasm

API

class LoadResult {
    value: any;
    header: Uint8Array;
    // Diagnostic[]-shaped: { offset: number, chunkId: number, structName: string, kind: string }
    diagnostics: any;
}

enum Engine { R2K, R2K3 }

function loadDatabase(bytes: Uint8Array): LoadResult;
function saveDatabase(value: any, engine: Engine, preserveHeader: boolean, header: Uint8Array): Uint8Array;

function loadMap(bytes: Uint8Array): LoadResult;
function saveMap(value: any, engine: Engine, preserveHeader: boolean, header: Uint8Array): Uint8Array;

function loadSave(bytes: Uint8Array): LoadResult;
function saveSave(value: any, engine: Engine, preserveHeader: boolean, header: Uint8Array): Uint8Array;

function loadTreeMap(bytes: Uint8Array): LoadResult;
function saveTreeMap(value: any, engine: Engine, preserveHeader: boolean, header: Uint8Array): Uint8Array;

Every loadX call always collects recoverable parse diagnostics (see the root crate's "Leniency" docs) rather than silently discarding them - diagnostics is usually an empty array. header is the file's original magic bytes; pass it back into saveX with preserveHeader: true to keep a non-canonical header byte-exact. Engine picks which RPG Maker's field layout to write, since R2K and R2K3 diverge on a handful of structs.

Usage

import init, { loadDatabase, saveDatabase, Engine } from "rm2k-wasm";

await init(); // browsers & Deno: no-arg init() works out of the box

const bytes = new Uint8Array(await Deno.readFile("./RPG_RT.ldb"));
const { value, header, diagnostics } = loadDatabase(bytes);
if (diagnostics.length > 0) console.warn(diagnostics);

value.system.system_name = "..."; // edit the loosely-typed value in place
const out = saveDatabase(value, Engine.R2K, true, header);

Under Node/Bun, init()'s default fetch()-based loading doesn't apply - pass the .wasm bytes explicitly instead:

import { readFile } from "node:fs/promises";
import init, { loadDatabase } from "rm2k-wasm";

await init(
  await readFile(new URL("./rm2k_wasm_bg.wasm", import.meta.resolve("rm2k-wasm"))),
);

Building

wasm-pack build --release --target web

Requires the wasm32-unknown-unknown rustup target (rustup target add wasm32-unknown-unknown) and wasm-pack (cargo binstall wasm-pack). Output goes to pkg/ (gitignored): the compiled .wasm, a JS glue module, a .d.ts, and the package.json this crate publishes to npm from.

Testing

wasm-pack test --node

Exercises the serde-wasm-bindgen conversion boundary against synthetic, guaranteed-valid values (Setup::defaults) rather than a real game file - see tests/smoke.rs.