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 🙏

© 2025 – Pkg Stats / Ryan Hefner

vdf-faster

v2.1.6

Published

a tools for turn to json to dota2's kv file.//Valve's KeyValues Text File Format serialization library

Readme

vdf-faster

一个高性能的 Valve Data Format (VDF) 解析器,专为 Dota 2 自定义游戏开发优化。 A high-performance Valve Data Format (VDF) parser optimized for Dota 2 custom game development.

特性 | Features

  • 🚀 高性能: 相比其他VDF解析器,提供更快的解析速度 High Performance: Provides faster parsing speed compared to other VDF parsers

  • 🎯 完整的#base支持: 正确处理和解析#base指令 Complete #base Support: Correctly handles and parses #base directives

  • 💪 健壮性: 完善的错误处理和边界情况支持 Robustness: Comprehensive error handling and edge case support

  • 🔄 双向转换: 支持VDF与JSON对象的双向转换 Bidirectional Conversion: Supports bidirectional conversion between VDF and JSON objects

  • 🎮 游戏开发优化: 专为Dota 2自定义游戏开发场景优化 Game Development Optimization: Specially optimized for Dota 2 custom game development scenarios

安装 | Installation

npm install vdf-faster

基础使用 | Basic Usage

import { decode, encode } from 'vdf-faster';

// VDF转JSON
// VDF to JSON
const vdfString = `
"root" {
    "key" "value"
    "nested" {
        "number" "42"
    }
}
`;

const jsonData = decode(vdfString);
console.log(jsonData);
// 输出 | Output: { root: { key: 'value', nested: { number: '42' } } }

// JSON转VDF
// JSON to VDF
const vdfOutput = encode(jsonData);
console.log(vdfOutput);
// 输出VDF格式字符串
// Outputs VDF formatted string

高级功能 | Advanced Features

#base文件处理 | #base File Handling

import { decode } from 'vdf-faster';

const vdfWithBase = `
#base "npc_units_custom.txt"
#base "npc_heroes_custom.txt"

"CustomUnits" {
    // ...
}
`;

// 处理#base指令
// Process #base directives
decode(vdfWithBase, (bases) => {
    console.log('Found base files:', bases);
    // 输出 | Output: ['npc_units_custom.txt', 'npc_heroes_custom.txt']
});

使用Decoder类 | Using the Decoder Class

import { decoder } from 'vdf-faster';

// 创建解码器实例
// Create decoder instance
const vdfDecoder = decoder.getNPCDecoder(vdfContent);

// 获取base文件列表
// Get base file list
const baseFiles = vdfDecoder.getBase();

// 获取解析后的数据
// Get parsed data
const jsonData = vdfDecoder.getDataJson('npc_dota_announcer_aghanim');

// 获取原始VDF格式数据
// Get original VDF formatted data
const vdfData = vdfDecoder.getDataCode('npc_dota_announcer_aghanim');

API文档 | API Documentation

decode(code: string, baseHandle?: (base: string[]) => void): Record<string, object>

将VDF格式字符串转换为JSON对象。

Converts VDF formatted string to JSON object.

  • code: 要解析的VDF格式字符串

    The VDF formatted string to parse

  • baseHandle: 可选的回调函数,用于处理#base指令

    Optional callback function for handling #base directives

  • 返回: 解析后的JSON对象

    Returns: Parsed JSON object

encode(data: any): string

将JSON对象转换为VDF格式字符串。

Converts JSON object to VDF formatted string.

  • data: 要转换的JSON对象

    The JSON object to convert

  • 返回: VDF格式字符串

    Returns: VDF formatted string

decoder类 | decoder Class

提供更细粒度的VDF解析控制:

Provides more granular VDF parsing control:

  • getBase(): 获取所有#base文件路径

    Get all #base file paths

  • getDataJson(key: string): 获取指定键的JSON格式数据

    Get JSON formatted data for the specified key

  • getDataCode(key: string): 获取指定键的VDF格式数据

    Get VDF formatted data for the specified key

性能对比 | Performance Comparison

| 解析器 Parser | 解析速度 Parse Speed | #base支持 #base Support | 备注 Notes | |--------|----------|------------|-------| | vdf-faster | 19.054ms | ✅ 完整支持 Complete | 性能优化,完整功能 Performance optimized, full features | | fast-vdf | 13.438ms | ❌ 不支持 Not supported | 性能最快但功能受限 Fastest but limited features | | vdferparser | 34.062ms | ❌ 解析错误 Parse error | - | | vdf-reader | 39.303ms | ⚠️ 部分支持 Partial | #base作为普通键处理 #base treated as regular key | | vdf-parser | 42.146ms | ❌ 解析错误 Parse error | - | | vdf-extra | 50.318ms | ✅ 支持 Supported | 不支持大文件 Doesn't support large files | | vdfjs | 87.78ms | ❌ 不支持 Not supported | - |

许可证 | License

MIT