@confuzzle/readpuz
Advanced tools
Comparing version 1.0.1 to 1.2.0
{ | ||
"name": "@confuzzle/readpuz", | ||
"version": "1.0.1", | ||
"version": "1.2.0", | ||
"description": "Minimal .puz format reader", | ||
@@ -17,4 +17,4 @@ "license": "MIT", | ||
"iconv-lite": "^0.5.2", | ||
"@confuzzle/puz-common": "^1.0.0" | ||
"@confuzzle/puz-common": "^1.2.0" | ||
} | ||
} |
@@ -45,2 +45,3 @@ const puz_common = require('@confuzzle/puz-common'); | ||
puz[name] = strings[i]; | ||
pos += strings[i].length + 1; | ||
} | ||
@@ -54,2 +55,32 @@ | ||
/* | ||
* Component Length (bytes) Description | ||
* Title 0x04 The name of the section | ||
* Length 0x02 The length of the data section, in bytes, not counting the null terminator | ||
* Checksum 0x02 A checksum of the data section | ||
* Data variable The data, which varies in format but is always terminated by null and has the specified length | ||
*/ | ||
puz.sections = []; | ||
for (let i = 0; i < puz.clues.length; i++) { | ||
pos += puz.clues[i].length + 1; | ||
} | ||
pos += 1; | ||
while ((pos + 8) < buf.length) { | ||
const title = buf.toString('utf8', pos, pos + 4); | ||
const len = buf.readUInt16LE(pos + 4); | ||
const checksum = buf.readUInt16LE(pos + 6); | ||
let data = null; | ||
if (title == 'RTBL' || title == 'LTIM') { | ||
data = buf.toString('utf8', pos + 8, pos + 8 + len); | ||
} else { | ||
data = new Uint8Array(buf.slice(pos + 8, pos + 8 + len)); | ||
} | ||
puz.sections.push({ | ||
title: title, | ||
data: data, | ||
checksum: checksum | ||
}); | ||
pos += 8 + len + 1; | ||
} | ||
return puz; | ||
@@ -56,0 +87,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4710
79
Updated@confuzzle/puz-common@^1.2.0