New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

kvparser

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kvparser

Parses VDF/KeyValues, used Steam and Source engine games

1.0.2
latest
Source
npm
Version published
Weekly downloads
5.8K
7.78%
Maintainers
1
Weekly downloads
 
Created
Source

KeyValues/VDF Parser

npm version npm downloads license sponsors

Parses Valve's KeyValues aka VDF format.

Fully compliant with escape sequences and comments.

Usage

Import the package:

const {parse} = require('kvparser');

or

import {parse} from 'kvparser';

parse(data)

Pass a string to the parse function, which will return an object. Since all KV structures begin with a named root key, the output object will have exactly one property, the value of which is an object.

Implementation Details

No extra processing is done to any data types. This means that all numbers are returned as strings. Additionally, proto-arrays are not automatically decoded into arrays. For example, this input data:

ExampleData
{
	"some_key_1"      "1"
	"some_key_2"      "1"
	"some_key_3"      "1"
}

Is decoded as:

{
	"ExampleData": {
		"some_key_1": "1",
		"some_key_2": "1",
		"some_key_3": "1"
	}
}

Any data after the closing } is ignored. Any sequence that begins with // and terminates with a newline is treated as a comment and is ignored.

Escape sequences are supported in quoted strings. Any backslash characters inside a quoted string are removed, and the following character is rendered as-is. Here are some example escape sequences and what they parse into:

  • "\"" becomes '"'
  • "\\" becomes '\\' (a string containing a single backslash, which JavaScript serializes into an escaped backslash)
  • "\n" becomes 'n'

Keywords

steam

FAQs

Package last updated on 22 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts