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

valve-key-values

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

valve-key-values

A simple parser of the KeyValues format from Valve

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-71.43%
Maintainers
0
Weekly downloads
 
Created
Source

valve-key-values

A simple parser of the KeyValues format from Valve

Usage

Parsing

import VKV from "valve-key-values"

const raw = `"Key1" "Value1"
"Key2"
{
	"Key3" "Value2"
	"Key4" "Value3"
	"Key5"
	{
		Key6 Value7
	}
}`;

interface ExampleObject extends VKV.VDFObject {
	Key1: string;
	Key2: {
		Key3: string;
		Key4: string;
		Key5: {
			Key6: string;
		}
	}
}

const parsed_object = VKV.parse<ExampleObject>(raw);
console.log("OUTPUT:\n", parsed_object);

OUTPUT:

{
	"Key1": "Value1",
	"Key2": {
		"Key3": "Value2",
		"Key4": "Value3",
		"Key5": {
			"Key6": "Value7"
		}
	}
}

Stringify

import VKV from "valve-key-values"
//The raw and ExampleObject values are in the Parsing section 
const parsed_object = VKV.parse<ExampleObject>(raw);
parsed_object.Key2.Key4 = "Test write"
console.log("OUTPUT:\n", VKV.strigify(parsed_object));

OUTPUT:

"Key1"	"Value1"
"Key2"
{
	"Key3"	"Value2"
	"Key4"	"Test write"
	"Key5"
	{
		"Key6"	"Value7"
	}
}

Keywords

FAQs

Package last updated on 30 Nov 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc