🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kvparser - npm Package Compare versions

Comparing version

to
1.0.2

@@ -5,9 +5,18 @@ "use strict";

/**
* @param {string|Buffer} input
* @return {object}
*/
exports.parse = function(input) {
if (Buffer.isBuffer(input)) {
// Support for environments where Buffer isn't defined
if (typeof Buffer == 'function' && Buffer.isBuffer(input)) {
input = input.toString('utf8');
}
if (typeof input != 'string') {
throw new Error(`Unexpected type "${typeof input}" for parameter 'input'`);
}
let parser = new KvParser(input);
return parser.parse();
};
{
"name": "kvparser",
"version": "1.0.1",
"version": "1.0.2",
"description": "Parses VDF/KeyValues, used Steam and Source engine games",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -11,2 +11,14 @@ "use strict";

let fileContent = FS.readFileSync(Path.join(__dirname, 'test_data', filename)).toString('utf8');
// Fix line endings if git mangled them
if (filename.endsWith('.eol-crlf.vdf')) {
// First replace all CRLF with LF, then LF with CRLF. This avoids ending up with \r\r\n
fileContent = fileContent.replace(/\r\n/g, '\n')
.replace(/\n/g, '\r\n');
}
if (filename.endsWith('.eol-lf.vdf')) {
fileContent = fileContent.replace(/\r\n/g, '\n');
}
return parse(fileContent);

@@ -78,2 +90,5 @@ }

let test230290 = parseFile('test230290.eol-lf.vdf');
assert.deepStrictEqual(test230290, require('./test_data/test230290.json'));
console.log('All tests passed');

@@ -80,0 +95,0 @@