s2cfgtojson 2.1.1 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/Struct.mts +17 -13
  2. package/package.json +1 -1
package/Struct.mts CHANGED
@@ -16,7 +16,7 @@ export type GetStructType<In> =
16
16
  : In extends Record<any, any>
17
17
  ? Struct<{ [key in RKey<In>]: GetStructType<In[key]> }>
18
18
  : In extends string
19
- ? string
19
+ ? In
20
20
  : In extends number
21
21
  ? number
22
22
  : In extends boolean
@@ -226,18 +226,22 @@ export abstract class Struct<T extends Entries = {}> {
226
226
  throw new Error(`Invalid key-value pair: ${line}`);
227
227
  }
228
228
  const key = match[1].trim();
229
- let value: string | number = match[3].trim();
230
- try {
231
- // understand 0.1f / 1. / 0.f / .1 / .1f -> ((\d*)\.?(\d+)|(\d+)\.?(\d*))f?
232
- const matches = value.match(/^(\d*)\.?(\d*)f?$/);
233
- const first = matches[1];
234
- const second = matches[2];
235
- if (first || second) {
236
- value = parseFloat(`${first || 0}${second ? `.${second}` : ""}`);
237
- } else {
238
- value = JSON.parse(value);
239
- }
240
- } catch (e) {}
229
+ let value: string | number | boolean = match[3].trim();
230
+ if (value === "true" || value === "false") {
231
+ value = value === "true";
232
+ } else {
233
+ try {
234
+ // understand 0.1f / 1. / 0.f / .1 / .1f -> ((\d*)\.?(\d+)|(\d+)\.?(\d*))f?
235
+ const matches = value.match(/^(\d*)\.?(\d*)f?$/);
236
+ const first = matches[1];
237
+ const second = matches[2];
238
+ if (first || second) {
239
+ value = parseFloat(`${first || 0}${second ? `.${second}` : ""}`);
240
+ } else {
241
+ value = JSON.parse(value);
242
+ }
243
+ } catch (e) {}
244
+ }
241
245
  Struct.addEntry(parent, key, value, index);
242
246
  };
243
247
  let index = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "s2cfgtojson",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "description": "Converts Stalker 2 Cfg file into a POJO",
5
5
  "keywords": [
6
6
  "stalker",