#browser #game #id #return #false #file-elem

aoe2rec-js

WASM version of aoe2rec to parse Age of Empires II: Definitive Edition recorded games in the browser

6 releases

new 0.1.9 Mar 30, 2025
0.1.8 Mar 3, 2025
0.1.7 Feb 22, 2025

#1045 in Web programming

Download history 242/week @ 2025-02-02 22/week @ 2025-02-09 175/week @ 2025-02-16 70/week @ 2025-02-23 131/week @ 2025-03-02 12/week @ 2025-03-09 1/week @ 2025-03-16

385 downloads per month

MIT license

13KB
250 lines

Age of Empires 2 Record parser

This is a WASM library to parse Age of Empires 2 DE save games

Usage

To use the library, pass a ArrayBuffer to the parse_rec function. Example:

<input type="file" id="fileElem">
import { parse_rec } from "aoe2rec-js";

const fileElem = document.getElementById("fileElem");
fileElem.addEventListener("change", event => {
  const files = (event.target as HTMLInputElement).files
  if (!files) {
    replayFile.value = null
    return
  }
  const file = files[0]
  const reader = new FileReader();
  reader.addEventListener('loadend', (event) => {
    try {
      const rec = parse_rec(event.target.result);
    } catch (error) {
      // It's important to catch errors because not all recs are guaranteed to parse correctly
      console.error("Failed to parse game");
    };
  }, false);
  reader.readAsArrayBuffer(file);

}, false);

Dependencies

~12MB
~223K SLoC