Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including @node-steam/vdf with all npm packages installed. Try it out:

const vdf = require('@node-steam/vdf'); const string = `"string" "string" "false" "false" "true" "true" "number" "1234" "float" "12.34" "null" "null" "undefined" "undefined" "nested" { "string" "string" "deep" { "string" "string" } }`; vdf.parse(string);

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@node-steam/vdf v2.1.0

Module to convert Valve's KeyValue format to JSON and back

Chat Travis CI Dependencies Version Downloads License Runkit

npm statistics

VDF is a module to convert Valve's KeyValue format to JSON and back using Typescript.

Heavily inspired by simple-vdf

(< v2.0.0 can be used as a drop-in replacement)

Differences

Installation

You can install VDF through the command line by using the following command:

yarn add @node-steam/vdf

Usage:

import * as VDF from '@node-steam/vdf';

// or

import {
    parse,
    stringify,
} from '@node-steam/vdf';

Documentation:

Generated Documentation

VDF.parse(text: string)

Parse a VDF string into a JSON object

const string = `
"string"          "string"
"false"           "false"
"true"            "true"
"number"          "1234"
"float"           "12.34"
"null"            "null"
"undefined"       "undefined"
"nested"
{
    "string"      "string"
    "deep"
    {
        "string"  "string"
    }
}
`;

const object = VDF.parse(string);

// or

const object = parse(string);

> {
    string:     'string',
    false:      false,
    true:       true,
    number:     1234,
    float:      12.34,
    null:       null,
    undefined:  undefined,
    nested: {
        string: 'string',
        deep: {
            string: 'string',
        },
    },
};

VDF.stringify(object: object)

Parse a JSON object into a VDF string

const object = {
    string:     'string',
    false:      false,
    true:       true,
    number:     1234,
    float:      12.34,
    null:       null,
    undefined:  undefined,
    nested: {
        string: 'string',
        deep: {
            string: 'string',
        },
    },
};

const string = VDF.stringify(object);

// or

const string = stringify(object);

> `
"string"          "string"
"false"           "false"
"true"            "true"
"number"          "1234"
"float"           "12.34"
"null"            "null"
"undefined"       "undefined"
"nested"
{
    "string"      "string"
    "deep"
    {
        "string"  "string"
    }
}
`;

Differences from simple-vdf

Contributors

Contributing:

Interested in contributing to VDF? Contributions are welcome, and are accepted via pull requests. Please review these guidelines before submitting any pull requests.

Help:

Installing dependencies:

yarn

Compile:

yarn compile

Test:

yarn test

Generate Docs:

yarn docs

Tests:

This module is thoroughly tested with ava

License:

Code licensed under MIT, documentation under CC BY 3.0.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free