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

gbx

v1.0.0-rc12

Published

a slim, fast and easy to set up Gamebox (GBX) parser written in TypeScript

Readme

gbx-ts

a slim, fast and easy to set up read-only Gamebox (GBX) parser written in TypeScript

Installation & Usage

Node.js

Install the package using your desired package manager.

gbx-ts is fully compatible with yarn, pnpm, deno and bun.

npm install gbx

Additionally, if you plan to process the body of GBX files, you will need to install the optional dependency lzo-ts. Please note that lzo-ts is licensed under the GPL-3.0 License.

npm install lzo-ts

Instantiate a new GBX object with a data stream. If you are using TypeScript, use a supported class as generic for full code completion.

import { GBX, CGameCtnChallenge } from 'gbx';
import { promises } from 'fs';

const stream = await promises.readFile('path/to/file.Map.Gbx');

const gbx = new GBX<CGameCtnChallenge>(stream);

const result = await gbx.parse();

console.log(result.mapName);

Web environment

If you are using the library in a web environment, you can include it directly from a CDN.

<script src="https://www.unpkg.com/gbx"></script>
<script lang="ts">
	const { GBX } = gbx;

	new GBX(stream);
	// ...
</script>

If you plan to process the body of GBX files, also add lzo-ts. Please note that it is licensed under the GPL-3.0 License.

<script src="https://www.unpkg.com/lzo-ts"></script>

Reference

Parameters

  • stream A Uint8Array or number array with the GBX file data.
  • loglevel (optional) A number to determine the loglevel.
    • 0 Errors only
    • 1 Warnings and errors (default)
    • 2 Info, warnings and errors
    • 3 Debug info, info, warnings and errors

Methods

  • parseHeaders() asynchronously parses the headers of the GBX file and returns the parsed class.
  • parse() Asynchronously parses the GBX file and returns the parsed class.
    • This method requires the optional dependency lzo-ts.

Game versions

gbx-ts provides a few methods to check the game version of the parsed GBX file taken from gbx-tool-api.

  • isTM2020() Returns true if the game is Trackmania 2020.
  • isManiaPlanet() Returns true if the game is based on ManiaPlanet (includes Turbo and 2020)
  • isTurbo() Returns true if the game is Trackmania Turbo. This method is not highly accurate.
  • isTMF() Returns true if the game is Trackmania Forever. This method is not highly accurate.

Utilities

gbx-ts comes with a few utility functions that you can import with import { Utils } from 'gbx';

  • Utils.getCheckpointCount(gbx: CGameCtnChallenge | CGameCtnGhost) Returns a number with the amount of checkpoints in a map or ghost.
  • Utils.getRespawnsCount(ghost: CGameCtnGhost) Returns a number with the amount of respawns in a ghost.
  • Utils.getCheckpointTimes(ghost: CGameCtnGhost) Returns an array with the checkpoint times in a ghost.
  • Utils.getSectorTimes(ghost: CGameCtnGhost) Returns an array with the sector times (delta of each checkpoint time) of a ghost.
  • Utils.getRespawnsByCheckpoint(ghost: CGameCtnGhost) Returns an array of the amount of respawns per checkpoint in a ghost.

Limitations

gbx-ts

  • is read-only, meaning it can only parse GBX files and not write them.
  • does not support all GBX file types, only the ones that have been implemented so far.
  • tries to read all chunks of each class, but there might be some unknown, although skippable, chunks. An exception are any form of MediaTracker data, as it is not yet implemented. gbx-ts will try to force skip these.

Please refer to alternative libraries if you need a more complete solution.

Supported GBX file types

| Class | File extension | | ------------------------------------------------------------ | ------------------------- | | CGameCtnChallenge | .Map.Gbx / .Challenge.Gbx | | CGameCtnReplayRecord | .Replay.Gbx | | CGameCtnGhost | .Ghost.Gbx |

License

  • gbx.js is licensed under the MIT License.
  • Processing the body of GBX files requires the use of the optional dependency lzo-ts, which is licensed under the GPL-3.0 License.

Credits

Special thanks to BigBang1112 for explaining his work on gbx-net, which was a great help in understanding the GBX file format, and giving me advice on how to improve the library.

Alternative libraries

  • gbx-net, a complete and in-depth read & write GBX parser library written in C#.
  • ManiaPlanetSharp, a GBX parser library and viewer written in C#.
  • pygbx, a GBX parser library written in Python.