GitHub - key-values/key-values-ts: A JavaScript/TypeScript parser for the KeyValues data format. (original) (raw)

A JavaScript/TypeScript parser for the KeyValues data format. KeyValues is an easy-to-use, JSON-like format developed by Valve Corporation. It is used in Steamworks configuration files as well as in several of Valve's games, such as Dota 2.

import KeyValues from 'key-values-ts';

const input = "key" { "key 1" "value 1" "key 2" "value 2" };

// Convert the KeyValues text to an object: const obj = KeyValues.parse(input); // { // key: { // 'key 1': 'value 1', // 'key 2': 'value 2' // } // }

// Convert the object back to a KeyValues text: const output = KeyValues.stringify(obj); // "key" // { // "key 1" "value 1" // "key 2" "value 2" // }