npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

counter-strike-2-demo-parser

v0.1.0

Published

CS2 demo (.dem) parser written from scratch in TypeScript. No third-party demo libraries.

Downloads

110

Readme

cs2-dem-parser

Parser de demos de CS2 (.dem) escrito desde cero en TypeScript.
Sin librerías de parsing de terceros — solo snappyjs para descompresión.

npm install cs2-dem-parser

Uso básico

import { parseDemo } from 'cs2-dem-parser'

const demo = parseDemo('./mi_partida.dem')

console.log(demo.map)       // "de_dust2"
console.log(demo.tickrate)  // 64
console.log(demo.players)   // [{ steamId, name, entityIndex }]
console.log(demo.rounds)    // [{ roundNumber, winningSide, reason, playerStats }]

API

parseDemo(filepath: string): ParsedDemo

Función de conveniencia. Parsea el archivo y retorna el resultado.

new DemoParser(filepath: string)

Clase principal si necesitás más control:

import { DemoParser } from 'cs2-dem-parser'

const parser = new DemoParser('./partida.dem')
const demo   = parser.parse()

Tipos

interface ParsedDemo {
  filename:  string
  map:       string
  tickrate:  number
  duration:  number          // segundos
  players:   ParsedPlayer[]
  rounds:    ParsedRound[]
}

interface ParsedPlayer {
  steamId:     string
  name:        string
  entityIndex: number
}

interface ParsedRound {
  roundNumber:  number
  winningSide:  'CT' | 'T'
  reason:       ParsedWinReason
  startTick:    number
  endTick:      number
  playerStats:  ParsedPlayerRoundStats[]
}

interface ParsedPlayerRoundStats {
  steamId:  string
  team:     'CT' | 'T'
  kills:    number
  deaths:   number
  assists:  number
  damage:   number
  survived: boolean
}

type ParsedWinReason =
  | 'CT_WIN_ELIMINATION'
  | 'T_WIN_ELIMINATION'
  | 'CT_WIN_DEFUSE'
  | 'T_WIN_BOMB_EXPLODED'
  | 'CT_WIN_TIME'
  | 'UNKNOWN'

Uso avanzado — pipeline manual

Podés acceder a las capas internas para construir tu propio pipeline:

import {
  DemoReader,
  extractNetMessages,
  parseGameEventList,
  decodeGameEvent,
  EVENTS_OF_INTEREST,
} from 'cs2-dem-parser'

const reader = new DemoReader('./partida.dem')
reader.readFileHeader()

for (const message of reader.messages()) {
  // Procesar cada mensaje a tu manera
  const netMsgs = extractNetMessages(message.data)
  for (const nm of netMsgs) {
    // ...
  }
}

Estructura interna

src/
├── index.ts                   ← API pública
├── parser/
│   ├── demoParser.ts          ← Orquestador principal
│   ├── demoReader.ts          ← Lee el stream de mensajes del .dem
│   ├── packetParser.ts        ← Extrae net messages de CDemoPacket
│   ├── gameEventListParser.ts ← Parsea el schema de eventos
│   ├── gameEventDecoder.ts    ← Decodifica eventos individuales
│   └── stringTableParser.ts  ← Resuelve jugadores por entityIndex
├── proto/
│   ├── protobufDecoder.ts     ← Decoder protobuf minimal (desde cero)
│   └── gameEvents.ts          ← Tipos y constantes de game events
├── types/
│   └── demo.ts                ← Tipos públicos
└── utils/
    ├── bufferReader.ts        ← Lector de bajo nivel sobre Buffer
    └── snappy.ts              ← Wrapper de descompresión Snappy

Limitaciones

  • Funciona con demos de matchmaking de Valve. Demos de FACEIT/ESEA pueden necesitar ajustes en el string table parser.
  • Las SendTables (posición tick a tick, HP, equipamiento) no están implementadas — es trabajo futuro.
  • Requiere Node.js >= 18.

Publicar en npm

# 1. Cambiar el "name" en package.json si está tomado
# 2. Login en npm
npm login

# 3. Build + tests + publish
npm publish

Licencia

MIT