s2cfgtojson 7.0.7 → 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 +13 -12
- 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;
|
|
@@ -33,8 +33,8 @@ export type GetStructType<In> =
|
|
|
33
33
|
? Struct & { [key: `${number}`]: GetStructType<In[typeof key]> }
|
|
34
34
|
: In extends Record<any, any>
|
|
35
35
|
? Struct & {
|
|
36
|
-
[key in keyof In]: key extends
|
|
37
|
-
?
|
|
36
|
+
[key in keyof In]: key extends Internal
|
|
37
|
+
? Struct[key]
|
|
38
38
|
: GetStructType<In[key]>;
|
|
39
39
|
}
|
|
40
40
|
: In extends string
|
|
@@ -90,7 +90,7 @@ const REF_INTERNAL_PROPS_INV = new Map(
|
|
|
90
90
|
* This file is part of the Stalker 2 Modding Tools project.
|
|
91
91
|
* This is a base class for all structs.
|
|
92
92
|
*/
|
|
93
|
-
export class Struct {
|
|
93
|
+
export class Struct implements Record<Internal, any> {
|
|
94
94
|
__internal__: Refs = new Refs();
|
|
95
95
|
|
|
96
96
|
/**
|
|
@@ -174,7 +174,7 @@ export class Struct {
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
entries<
|
|
177
|
-
K extends Exclude<keyof this,
|
|
177
|
+
K extends Exclude<keyof this, InternalPlus>,
|
|
178
178
|
V extends (typeof this)[K],
|
|
179
179
|
>() {
|
|
180
180
|
return Object.entries(this).filter(
|
|
@@ -182,9 +182,10 @@ export class Struct {
|
|
|
182
182
|
) as [K, V][];
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
forEach<
|
|
186
|
-
|
|
187
|
-
|
|
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 {
|
|
188
189
|
this.entries().forEach(([key, value], i, arr) =>
|
|
189
190
|
callback([key as K, value as V], i, arr as any),
|
|
190
191
|
);
|
|
@@ -195,7 +196,7 @@ export class Struct {
|
|
|
195
196
|
* @param callback
|
|
196
197
|
*/
|
|
197
198
|
filter<
|
|
198
|
-
K extends Exclude<keyof this,
|
|
199
|
+
K extends Exclude<keyof this, InternalPlus>,
|
|
199
200
|
V extends (typeof this)[K],
|
|
200
201
|
S extends this,
|
|
201
202
|
>(callback: (value: [K, V], index: number, array: [K, V][]) => boolean): S {
|
|
@@ -212,7 +213,7 @@ export class Struct {
|
|
|
212
213
|
* Maps the struct entries based on a callback function. Returns a copy.
|
|
213
214
|
* @param callback
|
|
214
215
|
*/
|
|
215
|
-
map<K extends Exclude<keyof this,
|
|
216
|
+
map<K extends Exclude<keyof this, InternalPlus>, V extends (typeof this)[K]>(
|
|
216
217
|
callback: ([key, value]: [K, V], i: number, arr: [K, V][]) => V,
|
|
217
218
|
): this {
|
|
218
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;
|