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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@voces/w3gjs

v2.5.3

Published

A native JavaScript WarCraft 3 replay parser implementation.

Downloads

229

Readme

w3gjs

Conventional Commits Build Status Test Coverage Maintainability

Parser

From scratch asynchronous, fully typed and tested TypeScript implementation of a w3g parser for WarCraft 3 replay files.

You can use the subcomponents to create your own parser that suits your requirements or just use the high-level parser output that is best suited for standard game mode game analysis.

It does not fully support replays of game version <= 1.14.

Installation

  npm install w3gjs

Usage

Check out the examples folder of this repository to find usage examples for both typescript and javascript.

For detailed API documentation check out https://pbug90.github.io/w3gjs Please keep in mind that as of now, parallel parsing with the same W3GReplay instance is not yet supported. Instantiate multiple instances or parse replays sequentially.

High Level API

High level API is best suited to parse standard melee replays.

const W3GReplay = require("w3gjs").default;
const parser = new W3GReplay();

(async () => {
  const result = await parser.parse("replay.w3g");
  console.log(result);
})().catch(console.error);

Low Level API

Low level API allows you to either implement your own logic on top of the ReplayParser class by extending it or to register callbacks to listen for parser events as it encounters the different kinds of blocks in a replay.

In previous versions, multiple events were emitted. In version 2 there are exactly two events.

basic_replay_information provides you with metadata about the replay that was parsed from the header information.

The gamedatablock event provides you with all blocks that make up the actual game data, fully parsed and in correct order. You can check their id property to distinguish the blocks from each other. For more information, consult the auto-generated docs for properties of specific blocks.

const ReplayParser = require("w3gjs/dist/lib/parsers/ReplayParser").default;
const fs = require("fs");
(async () => {
  const buffer = fs.readFileSync("./reforged1.w3g");
  const parser = new ReplayParser();
  parser.on("basic_replay_information", (info) => console.log(info));
  parser.on("gamedatablock", (block) => console.log(block));
  const result = await parser.parse(buffer);
  console.log(result);
})().catch(console.error);

Contributing

There is no point in hiding the implementation of tools that the community can use. So please feel free to discuss in the issues section or provide a pull request if you think you can improve this parser.

Issues

If you have an issue using this library please use the issue section and provide an example replay file.

License

MIT license, see LICENSE.md file.