Comparing version
11
index.js
@@ -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 @@ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
2944087
391.4%28
7.69%28921
260.12%1
Infinity%