1
0
Fork 0
mirror of https://github.com/demostf/demo.js synced 2026-06-04 00:54:14 +02:00
TF2 demo parsing in javascript
  • TypeScript 95.5%
  • JavaScript 4.3%
  • Makefile 0.2%
Find a file
Narcha ac467e9b74
Fixed node compatibility
As far as I can tell, the old dependency is a fork of the original text-encoding-shim with a patch that fixed compatibility with node.
The fork has been unmaintained for three years.
Since then, the original has been updated, making the fork obsolete.
Also, newer node versions have deprecated `GLOBAL` in favor of `global`.
This breaks compatibility with the fork and causes demos.tf to crash on node v16.2.0. The original has been updated to fix this incompatibility, see commit
142068f3a2 .
2021-06-11 01:28:18 +02:00
bin update codegen 2019-08-12 13:29:47 +02:00
src update codegen 2019-08-12 13:29:47 +02:00
.gitignore code style and add tslint 2017-07-30 22:45:58 +02:00
.npmignore add test for new celt codec 2017-02-17 23:18:45 +01:00
.travis.yml only test latest nodejs 2017-12-09 17:09:28 +01:00
index.js final typescript conversion 2016-12-18 20:15:18 +01:00
LICENCE Create LICENCE 2017-02-17 23:56:45 +01:00
Makefile re-enable es6 output 2017-12-09 18:58:08 +01:00
mocha.opts long timeout for travis 2017-12-09 18:58:08 +01:00
package-lock.json bumb dependencies 2019-02-09 15:20:17 +01:00
package.json Fixed node compatibility 2021-06-11 01:28:18 +02:00
README.md 2.0.2 2017-12-16 12:39:28 +01:00
tsconfig.es6.json re-enable es6 output 2017-12-09 18:58:08 +01:00
tsconfig.json use Map instead of Object for gameEventList 2017-09-02 15:23:00 +02:00
tslint.json lint fixes 2017-09-26 02:29:45 +02:00
typings.json add basic snapshot test 2017-02-12 16:33:30 +01:00
unit.mocha.opts unit tests for parser generator 2017-08-12 14:22:31 +02:00

demo.js

Build Status

Parsing of TF2 demo files in node.js and the browser

usage

cli

node bin/analyse demo.dem

api

var Demo = require('@demostf/demo.js');
var fs = require('fs');

fs.readFile("example.dem", function (err, data) {
	if (err) throw err;
	var demo = Demo.fromNodeBuffer(data);
	var analyser = demo.getAnalyser();
	var head = analyser.getHeader();
	console.log(head);
	var body = analyser.getBody();
	console.log(body.getState());
});

more information from packets

Using the javascript api it's possible to get far more information out of a demo file than the basic state provided by the cli interface.

var Demo = require('@demostf/demo.js');
var fs = require('fs');

fs.readFile("example.dem", function (err, data) {
	if (err) throw err;
	var demo = Demo.fromNodeBuffer(data);
	var analyser = demo.getAnalyser();
	var head = analyser.getHeader();
	var match = analyser.match;
	for (const packet of analyser.getPackets()) {
		// where you can either get information directly from the packet (see ./src/Data/Packet.ts)
		// or use the `match` object which has contains an (incomplete) state of the match at the current tick
	}
});

A note on POV demos

During the development of this project the main focus has always been on parsing STV demos. Although there are currently no known issues iwth POV demos parsing them is a lot more error prone.

Credits

Special thanks goes to

Without the information provided by these projects this would not have been possible