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 🙏

© 2024 – Pkg Stats / Ryan Hefner

binary-vdf-parser

v1.0.2

Published

Valve Binary VDF file parser for Node.js

Downloads

9

Readme

Binary VDF Parser

NPM NPM License GitHub Issues GitHub PRs

binary-vdf-parser is a module for parsing Valve binary VDF files such as appinfo.vdf or shortcuts.vdf. It was created for the Skizzium Launcher after encountering issues parsing appinfo.vdf with existing packages such as steam-binary-vdf and binary-vdf.

Usage

Install with npm i --save binary-vdf-parser

import fs from 'fs';
import path from 'path';
import { readVdf } from './index';

const filepath = path.resolve('path/to/file.vdf');
const buffer = fs.readFileSync(filepath);
const appinfo = readVdf(buffer);

console.log(appinfo);

Decoding Guide

VDFs are formatted in LE (little endian), meaning multi-byte values should be interpreted right-to-left. For example, a 16bit integer 0x01 0x00 should be interpreted as 1 instead of 256. In Node.js, use buffer.readUInt32LE() to read a 32bit unsigned integer.

There are a few bytes that will appear before any data. These bytes indicate which type of data will follow:

  • The first data type is a map (or object, in JS terms), represented by 0x00. The next byte will be the first entry inside of this new map.
  • The second data type is a string, represented by 0x01. The string is utf8-encoded, lasting until a NULL terminator is found (0x00). This is the only exception to 0x00, changing the meaning from "Create a new map" to "Reached the end of a string". No other data types end in 0x00.
  • The third data type is an integer, represented by 0x02. This is an unsigned 32bit int, meaning it will always consume exactly 4 bytes.
  • The last data type indicates the end of a map, represented by 0x08. The next byte will be the beginning of the next entry in the "parent" map.

My Notes

Below are the notes I took while learning the data. I opened an appinfo.vdf file with HxD (a hex editor) and went through each byte, comparing it to a premade JSON dump. I mentally converted each byte into the following symbols and added plaintext/numbers where it called for them. I then used the symbols' descriptions to convert it to JSON until I felt I got the hang of it and could write it in code.

; 0x00: Null terminator (terminate string if possible, otherwise begin map)
" 0x01: New property (string)
# 0x02: New property (int)
< 0x08: End map

appinfo;#appid;7;common;"name;Steam Client;"type;Config;;associations;<#gameid;7<;extended;"beta_name_1;Steam Beta Update;"

[
  {
    appid: 7,
    common: {
      name: 'Steam Client',
      type: 'Config',
      associations: {}
    },
    gameid: 7,
    extended: {
      beta_name_1: 'Steam Beta Update',
      beta_contentlist_1: 'steamexe publicbeta',
      beta_name_2: 'Steam Deck Stable',
      beta_contentlist_2: 'steamexe steamdeck_stable',
      beta_name_3: 'Steam Deck Beta',
      // ...
    }
  }
]