@slippilab/parser
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

Parser

A basic browser-friendly .slp file parser.

The official @slippi/slippi-js parser is maintained by the Slippi team, is more feature rich, and is always up to date. However, it relies on Node's Buffer structs and has other features that are not browser-compatible. It is possible to use the official parser in the browser with the right polyfills and build tooling, but doing so can add a lot complexity to some web apps.

Fields up to spec version 3.9.0.0 are currently supported. The .slp file specification can be found here.

If a field is not present, likely because the format was expanded after the replay was created, it is left undefined instead of throwing an error. This is intentionally not reflected in the types to make them more convenient to work with, but will be occasionally inaccurate. If these missing data cases are important to you, consider checking the Game.formatVersion string for the replay or wrapping the parser types in Partial<T> or DeepPartial<T>.

Install

Yarn

yarn add @slippilab/parser

npm

npm install @slippilab/parser

URL import from a CDN

import { Game } from 'https://cdn.skypack.dev/@slippilab/parser';

Example

<html>
  <script type="module">
    import { Game } from 'https://cdn.skypack.dev/@slippilab/parser';
    const input = document.querySelector('#replayInput');
    input.onchange = async () =>
      console.log(new Game(await input.files[0].arrayBuffer()));
  </script>
  <input id="replayInput" type="file"/>
</html>

Future work ideas

  1. Finish exposing various fields from the file. There are a lot of less important fields are still left as TODOs.
  2. Add unit test coverage.
  3. Re-organize the data structures to be more convenient. Right now it more or less follows the spec format.
  4. Offer enums/helpers for working with the IDs.

Readme

Keywords

none

Package Sidebar

Install

npm i @slippilab/parser

Weekly Downloads

0

Version

0.0.5

License

MIT

Unpacked Size

4.33 MB

Total Files

11

Last publish

Collaborators

  • frankborden