s2cfgtojson 2.0.1 → 2.0.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 +10 -7
  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
 
@@ -125,13 +126,15 @@ export abstract class Struct<T extends Entries = {}> {
125
126
  const collect = (struct: Struct) => {
126
127
  const obj = {};
127
128
  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
- });
129
+ Object.entries(struct.entries)
130
+ .filter(([key]) => !defaultEntries.has(key))
131
+ .forEach(([key, value]) => {
132
+ if (value instanceof Struct) {
133
+ obj[key] = collect(value);
134
+ } else {
135
+ obj[key] = value;
136
+ }
137
+ });
135
138
  }
136
139
  return obj;
137
140
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "s2cfgtojson",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "Converts Stalker 2 Cfg file into a POJO",
5
5
  "keywords": [
6
6
  "stalker",