s2cfgtojson 2.0.1 → 2.0.3

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 -8
  2. package/package.json +1 -1
package/Struct.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  export type Value = Omit<Struct, "toTs"> | string | boolean | number;
2
+ const defaultEntries = new Set(["_isArray", "_useAsterisk"]);
2
3
  type DefaultEntries = { _isArray?: boolean; _useAsterisk?: boolean };
3
4
  export type Entries = Record<string | number, Value> & DefaultEntries;
4
5
 
@@ -10,7 +11,13 @@ export type GetTsType<In extends Struct, E = In["entries"]> = {
10
11
  export type GetStructType<In extends Record<string | number, any>> = Struct<{
11
12
  [key in Exclude<keyof In, keyof DefaultEntries>]: In[key] extends In
12
13
  ? GetStructType<In[key]>
13
- : In[key];
14
+ : In[key] extends string
15
+ ? string
16
+ : In[key] extends number
17
+ ? number
18
+ : In[key] extends boolean
19
+ ? boolean
20
+ : In[key];
14
21
  }>;
15
22
 
16
23
  /**
@@ -125,13 +132,15 @@ export abstract class Struct<T extends Entries = {}> {
125
132
  const collect = (struct: Struct) => {
126
133
  const obj = {};
127
134
  if (struct.entries) {
128
- Object.entries(struct.entries).forEach(([key, value]) => {
129
- if (value instanceof Struct) {
130
- obj[key] = collect(value);
131
- } else {
132
- obj[key] = value;
133
- }
134
- });
135
+ Object.entries(struct.entries)
136
+ .filter(([key]) => !defaultEntries.has(key))
137
+ .forEach(([key, value]) => {
138
+ if (value instanceof Struct) {
139
+ obj[key] = collect(value);
140
+ } else {
141
+ obj[key] = value;
142
+ }
143
+ });
135
144
  }
136
145
  return obj;
137
146
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "s2cfgtojson",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "Converts Stalker 2 Cfg file into a POJO",
5
5
  "keywords": [
6
6
  "stalker",