1
0
Fork 0
mirror of https://github.com/demostf/demo.js synced 2026-06-03 16:44:12 +02:00
TF2 demo parsing in javascript
  • TypeScript 95.5%
  • JavaScript 4.3%
  • Makefile 0.2%
Find a file
2017-04-08 21:58:20 +02:00
bin cleanup bin 2017-03-07 18:17:58 +01:00
src type 2017-03-17 22:53:14 +01:00
typings add basic snapshot test 2017-02-12 16:33:30 +01:00
.babelrc code organization and some es6 2016-12-18 15:12:55 +01:00
.gitignore initial typescript conversions 2016-12-18 15:37:29 +01:00
.npmignore add test for new celt codec 2017-02-17 23:18:45 +01:00
.travis.yml add travis configuration 2017-03-10 19:52:47 +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 add seperate build with es6 modules 2017-02-18 23:59:11 +01:00
mocha.opts add basic snapshot test 2017-02-12 16:33:30 +01:00
package.json use released bit-buffer 2017-04-08 21:58:20 +02:00
README.md update readme 2017-03-10 20:00:56 +01:00
tsconfig.es6.json add seperate build with es6 modules 2017-02-18 23:59:11 +01:00
tsconfig.json add test for new celt codec 2017-02-17 23:18:45 +01:00
typings.json add basic snapshot test 2017-02-12 16:33:30 +01: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('tf2-demo');
var fs = require('fs');

fs.readFile("example.dem", function (err, data) {
	if (err) throw err;
	var demo = Demo.fromNodeBuffer(data);
	var parser = demo.getParser();
	var head = parser.readHeader();
	console.log(head);
	var body = parser.parseBody();
	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('tf2-demo');
var fs = require('fs');

fs.readFile("example.dem", function (err, data) {
	if (err) throw err;
	var demo = Demo.fromNodeBuffer(data);
	var parser = demo.getParser();
	var head = parser.readHeader();
	var match = parser.match;
	parser.on('packet', function(packet) {
		// 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
	});
	parser.parseBody();
});

A note on POV demos

During the development of this project the main focus has always been on parsing STV demos. Parsing POV demos is a lot more error prone and has known issues.

Credits

Special thanks goes to

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