s2cfgtojson 7.0.6 → 7.0.8
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 +16 -11
- package/Struct.test.mts +5 -0
- package/package.json +1 -1
package/Struct.mts
CHANGED
|
@@ -11,10 +11,10 @@ export type Internal =
|
|
|
11
11
|
| "forEach"
|
|
12
12
|
| "filter"
|
|
13
13
|
| "map"
|
|
14
|
-
| "fromJson"
|
|
15
14
|
| "toJson"
|
|
16
|
-
| "toString"
|
|
17
|
-
|
|
15
|
+
| "toString";
|
|
16
|
+
|
|
17
|
+
export type InternalPlus = Internal | "fromString" | "fromJson";
|
|
18
18
|
|
|
19
19
|
export interface DefaultEntries {
|
|
20
20
|
bpatch?: boolean;
|
|
@@ -32,7 +32,11 @@ export type GetStructType<In> =
|
|
|
32
32
|
In extends Array<any>
|
|
33
33
|
? Struct & { [key: `${number}`]: GetStructType<In[typeof key]> }
|
|
34
34
|
: In extends Record<any, any>
|
|
35
|
-
? Struct & {
|
|
35
|
+
? Struct & {
|
|
36
|
+
[key in keyof In]: key extends Internal
|
|
37
|
+
? Struct[key]
|
|
38
|
+
: GetStructType<In[key]>;
|
|
39
|
+
}
|
|
36
40
|
: In extends string
|
|
37
41
|
? In
|
|
38
42
|
: In extends number
|
|
@@ -86,7 +90,7 @@ const REF_INTERNAL_PROPS_INV = new Map(
|
|
|
86
90
|
* This file is part of the Stalker 2 Modding Tools project.
|
|
87
91
|
* This is a base class for all structs.
|
|
88
92
|
*/
|
|
89
|
-
export class Struct {
|
|
93
|
+
export class Struct implements Record<Internal, any> {
|
|
90
94
|
__internal__: Refs = new Refs();
|
|
91
95
|
|
|
92
96
|
/**
|
|
@@ -170,7 +174,7 @@ export class Struct {
|
|
|
170
174
|
}
|
|
171
175
|
|
|
172
176
|
entries<
|
|
173
|
-
K extends Exclude<keyof this,
|
|
177
|
+
K extends Exclude<keyof this, InternalPlus>,
|
|
174
178
|
V extends (typeof this)[K],
|
|
175
179
|
>() {
|
|
176
180
|
return Object.entries(this).filter(
|
|
@@ -178,9 +182,10 @@ export class Struct {
|
|
|
178
182
|
) as [K, V][];
|
|
179
183
|
}
|
|
180
184
|
|
|
181
|
-
forEach<
|
|
182
|
-
|
|
183
|
-
|
|
185
|
+
forEach<
|
|
186
|
+
K extends Exclude<keyof this, InternalPlus>,
|
|
187
|
+
V extends (typeof this)[K],
|
|
188
|
+
>(callback: ([key, value]: [K, V], i: number, arr: [K, V][]) => void): void {
|
|
184
189
|
this.entries().forEach(([key, value], i, arr) =>
|
|
185
190
|
callback([key as K, value as V], i, arr as any),
|
|
186
191
|
);
|
|
@@ -191,7 +196,7 @@ export class Struct {
|
|
|
191
196
|
* @param callback
|
|
192
197
|
*/
|
|
193
198
|
filter<
|
|
194
|
-
K extends Exclude<keyof this,
|
|
199
|
+
K extends Exclude<keyof this, InternalPlus>,
|
|
195
200
|
V extends (typeof this)[K],
|
|
196
201
|
S extends this,
|
|
197
202
|
>(callback: (value: [K, V], index: number, array: [K, V][]) => boolean): S {
|
|
@@ -208,7 +213,7 @@ export class Struct {
|
|
|
208
213
|
* Maps the struct entries based on a callback function. Returns a copy.
|
|
209
214
|
* @param callback
|
|
210
215
|
*/
|
|
211
|
-
map<K extends Exclude<keyof this,
|
|
216
|
+
map<K extends Exclude<keyof this, InternalPlus>, V extends (typeof this)[K]>(
|
|
212
217
|
callback: ([key, value]: [K, V], i: number, arr: [K, V][]) => V,
|
|
213
218
|
): this {
|
|
214
219
|
const clone = this.clone();
|
package/Struct.test.mts
CHANGED
|
@@ -6,6 +6,8 @@ import {
|
|
|
6
6
|
Struct,
|
|
7
7
|
ArmorPrototype,
|
|
8
8
|
Refs,
|
|
9
|
+
QuestNodePrototypeRandom,
|
|
10
|
+
QuestNodePrototypeLaunchers,
|
|
9
11
|
} from "./Struct.mjs";
|
|
10
12
|
import fs from "node:fs";
|
|
11
13
|
|
|
@@ -481,3 +483,6 @@ struct.end`);
|
|
|
481
483
|
const MyRank: ERank = "ERank::Experienced, ERank::Veteran, ERank::Master";
|
|
482
484
|
// noinspection BadExpressionStatementJS
|
|
483
485
|
({}) as ArmorPrototype["MeshGenerator"];
|
|
486
|
+
|
|
487
|
+
(new Struct() as QuestNodePrototypeRandom).Launchers =
|
|
488
|
+
{} as QuestNodePrototypeLaunchers;
|