Skip to content
This repository was archived by the owner on Jun 25, 2022. It is now read-only.
/ key-values-ts Public archive

A JavaScript/TypeScript parser for the KeyValues data format.

License

Notifications You must be signed in to change notification settings

key-values/key-values-ts

Folders and files

NameName
Last commit message
Last commit date
Jul 2, 2020
Jun 16, 2020
Oct 23, 2020
Jul 5, 2020
Jun 16, 2020
Jun 18, 2020
Jun 18, 2020
Jun 16, 2020
Jun 17, 2020
Jul 2, 2020
Apr 29, 2021
Jun 20, 2020
Apr 3, 2022

Repository files navigation

KeyValues.ts

npm package npm downloads CI status Codecov coverage License

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.

Installation

Using yarn:

yarn add key-values-ts

Using npm:

npm install key-values-ts

Usage

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"
// }