Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Built and signed on GitHub Actions
latest
NeKzor/sdpSimple Source Engine demo parser. 🔧
This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers




JSR Score
70%
Published
11 months ago (0.10.1)
sdp
Simple Source Engine demo parser. Try it out on StackBlitz!
Features
- Support for multiple engines
- Portal 2
- Half-Life 2
- Custom engine, see Strata Source example
- Optional decoding of message data
- Speedrun timing
- Rules for Portal, Portal 2 and mods
- SAR timing
- Utils
- Steam ID parsing
- SAR data
Examples
Read header only
Using Deno + TypeScript:
import { SourceDemoParser } from 'jsr:@nekz/sdp'; const demo = SourceDemoParser.default() .setOptions({ messages: false }) .parse(Deno.readFileSync('demo.dem')); console.log(demo); /* SourceDemo { demoFileStamp: 'HL2DEMO', demoProtocol: 3, networkProtocol: 15, serverName: 'localhost:0', clientName: 'Can\'t Even', mapName: 'testchmb_a_00', gameDirectory: 'portal', playbackTime: 3.944999933242798, playbackTicks: 263, playbackFrames: 253, signOnLength: 80641, messages: [] } */
Read UserCmd messages
Using Node + JavaScript:
import fs from 'node:fs'; import { DemoMessages, SourceDemoParser } from '@nekz/sdp'; const demo = SourceDemoParser.default() .setOptions({ userCmds: true }) .parse(fs.readFileSync('demo.dem')); const IN_JUMP = 1 << 1; const registeredJumps = demo .findMessages(DemoMessages.UserCmd) .filter(({ userCmd }) => userCmd.buttons & IN_JUMP); console.log('registered jumps:', registeredJumps.length); /* registered jumps: 270 */
The examples directory contains more examples for Node and Deno.
View Origin
Used in nekz.me/parser. Updated example can be found in examples/web/parser.html.
Dependencies
Vendored inolen/bit-buffer for TypeScript port + improvements.
License
Built and signed on
GitHub Actions
Add Package
deno add jsr:@nekz/sdp
Import symbol
import * as sdp from "@nekz/sdp";
Import directly with a jsr specifier
import * as sdp from "jsr:@nekz/sdp";
Add Package
pnpm i jsr:@nekz/sdp
pnpm dlx jsr add @nekz/sdp
Import symbol
import * as sdp from "@nekz/sdp";
Add Package
yarn add jsr:@nekz/sdp
yarn dlx jsr add @nekz/sdp
Import symbol
import * as sdp from "@nekz/sdp";
Add Package
vlt install jsr:@nekz/sdp
Import symbol
import * as sdp from "@nekz/sdp";
Add Package
npx jsr add @nekz/sdp
Import symbol
import * as sdp from "@nekz/sdp";
Add Package
bunx jsr add @nekz/sdp
Import symbol
import * as sdp from "@nekz/sdp";
