s2cfgtojson 3.2.2 → 3.2.4

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.
package/Struct.mts CHANGED
@@ -21,7 +21,7 @@ const INTERNAL_PROPS = new Set([
21
21
  "filter",
22
22
  "map",
23
23
  "toString",
24
- ]);
24
+ ] satisfies Array<keyof Struct>);
25
25
 
26
26
  /**
27
27
  * This file is part of the Stalker 2 Modding Tools project.
@@ -94,17 +94,21 @@ export class Struct {
94
94
  return Struct.fromString(this.toString())[0] as this;
95
95
  }
96
96
 
97
- entries(): [keyof this, (typeof this)[keyof this]][] {
98
- return Object.entries(this).filter(([key]) => !INTERNAL_PROPS.has(key)) as [
99
- keyof this,
100
- (typeof this)[keyof this],
101
- ][];
97
+ entries<
98
+ K extends Exclude<keyof this, Internal>,
99
+ V extends (typeof this)[K],
100
+ >() {
101
+ return Object.entries(this).filter(
102
+ ([key]) => !INTERNAL_PROPS.has(key as any),
103
+ ) as [K, V][];
102
104
  }
103
105
 
104
106
  forEach<K extends Exclude<keyof this, Internal>, V extends (typeof this)[K]>(
105
- callback: ([key, value]: [K, V]) => void,
107
+ callback: ([key, value]: [K, V], i: number, arr: [K, V][]) => void,
106
108
  ): void {
107
- this.entries().forEach(([key, value]) => callback([key as K, value as V]));
109
+ this.entries().forEach(([key, value], i, arr) =>
110
+ callback([key as K, value as V], i, arr as any),
111
+ );
108
112
  }
109
113
 
110
114
  /**
@@ -112,11 +116,11 @@ export class Struct {
112
116
  * @param callback
113
117
  */
114
118
  filter<K extends Exclude<keyof this, Internal>, V extends (typeof this)[K]>(
115
- callback: ([key, value]: [K, V]) => boolean,
119
+ callback: ([key, value]: [K, V], i: number, arr: [K, V][]) => boolean,
116
120
  ): Partial<this> & Struct {
117
121
  const clone = this.clone();
118
- clone.entries().forEach(([key, value]) => {
119
- if (!callback([key as K, value as V])) {
122
+ clone.entries().forEach(([key, value], i, arr) => {
123
+ if (!callback([key as K, value as V], i, arr as any)) {
120
124
  delete clone[key];
121
125
  }
122
126
  });
@@ -128,11 +132,11 @@ export class Struct {
128
132
  * @param callback
129
133
  */
130
134
  map<K extends Exclude<keyof this, Internal>, V extends (typeof this)[K]>(
131
- callback: ([key, value]: [K, V]) => V,
135
+ callback: ([key, value]: [K, V], i: number, arr: [K, V][]) => V,
132
136
  ): this {
133
137
  const clone = this.clone();
134
- clone.entries().forEach(([key, value]) => {
135
- clone[key] = callback([key as K, value as V]);
138
+ clone.entries().forEach(([key, value], i, arr) => {
139
+ clone[key] = callback([key as K, value as V], i, arr as any);
136
140
  });
137
141
  return clone;
138
142
  }
@@ -154,8 +158,7 @@ export class Struct {
154
158
 
155
159
  text += "\n";
156
160
  // Add all keys
157
- text += Object.entries(this)
158
- .filter(([key]) => !INTERNAL_PROPS.has(key))
161
+ text += this.entries()
159
162
  .map(([key, value]) => {
160
163
  const nameAlreadyRendered =
161
164
  value instanceof Struct && value.__internal__.rawName;
@@ -165,7 +168,7 @@ export class Struct {
165
168
  let equalsOrColon = "";
166
169
  let spaceOrNoSpace = "";
167
170
  if (!nameAlreadyRendered) {
168
- keyOrIndex = renderKeyName(key, useAsterisk) + " ";
171
+ keyOrIndex = renderKeyName(key as string, useAsterisk) + " ";
169
172
  equalsOrColon = value instanceof Struct ? ":" : "=";
170
173
  spaceOrNoSpace = value === "" ? "" : " ";
171
174
  }
package/Struct.test.mts CHANGED
@@ -318,6 +318,4 @@ struct.end`;
318
318
  // noinspection JSUnusedLocalSymbols
319
319
  const MyRank: ERank = "ERank::Experienced, ERank::Veteran, ERank::Master";
320
320
  // noinspection BadExpressionStatementJS
321
- (({}) as ArmorPrototype["MeshGenerator"]).forEach(([_k, e]) => {
322
- e.Cost *= 2;
323
- });
321
+ ({}) as ArmorPrototype["MeshGenerator"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "s2cfgtojson",
3
- "version": "3.2.2",
3
+ "version": "3.2.4",
4
4
  "description": "Converts Stalker 2 Cfg file into POJOs",
5
5
  "keywords": [
6
6
  "stalker",