screp-js

0.3.0 • Public • Published

Apache 2.0 license npm version screp v1.7.2

screp-js

A pure Javascript version of screp, a StarCraft: Remastered replay file parser, compiled from the original Go version using GopherJS.

screp (StarCraft: Brood War Replay Parser) is a library for extracting information from StarCraft replay files. This library is based on a recompiled version of that library for Javascript. It's designed to parse file buffers of .rep files—if you want an easier interface aimed at parsing files through Node, try screp-js-file.

This wrapper is usable both as a CommonJS module and as a browser global.

Installation

This library can be installed through npm:

npm i --save screp-js

This library is about 367 KB gzipped (and 1,3 MB otherwise), as the compiled code generated by GopherJS is quite large.

Usage

The screp library can be either included in an HTML page, in which case it will be added to the global namespace as Screp, or it can be imported as a CommonJS module:

const Screp = require('screp-js')

const processRep(uint8arr) {
  try {
    // 'uint8arr' is a Uint8Array containing a .rep file.
    const res = await Screp.parseBuffer(uint8arr)
    return res
  }
  catch (err) {
    // If something went wrong, 'err' will be an Error object containing a string thrown by Go.
    console.log(err)
  }
}

Reference

Function:

Screp.parseBuffer(uint8arr[, {options}])

Parameters:

  • uint8arr Uint8Array
    the command to parse
  • options object (optional)
    a set of options used to change parsing behavior:
    • header boolean: true
      include replay header
    • computed boolean: true
      print computed/derived data
    • mapData boolean: false
      include map data
    • mapTiles boolean: false
      include map tiles; valid with mapData
    • mapResLoc boolean: false
      print map data resource locations (minerals and geysers); valid with mapData
    • cmds boolean: false
      print player commands

Returns:

  • Promise (object): the same data as you'd get from the screp command line tool

The defaults are the same as those for the screp command line tool.


Function:

Screp.getVersion()

Returns:

  • string: the same version information as you'd get from screp -version

Function:

Screp.getVersionObject()

Returns:

  • object: version information in object form, with only the pertinent information included

External links

Copyright

Apache License 2.0, as per the original screp project.

Package Sidebar

Install

npm i screp-js

Weekly Downloads

0

Version

0.3.0

License

Apache-2.0

Unpacked Size

1.38 MB

Total Files

9

Last publish

Collaborators

  • msikma