s2cfgtojson 7.0.1 → 7.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.
- package/Struct.mts +14 -3
- package/Struct.test.mts +12 -1
- package/package.json +1 -1
package/Struct.mts
CHANGED
|
@@ -24,6 +24,7 @@ export interface DefaultEntries {
|
|
|
24
24
|
rawName?: string;
|
|
25
25
|
refkey?: string | number;
|
|
26
26
|
refurl?: string;
|
|
27
|
+
removenode?: boolean;
|
|
27
28
|
useAsterisk?: boolean;
|
|
28
29
|
}
|
|
29
30
|
|
|
@@ -130,7 +131,11 @@ export class Struct {
|
|
|
130
131
|
"Cannot remove node from non-patch struct. Use fork() first.",
|
|
131
132
|
);
|
|
132
133
|
}
|
|
133
|
-
this[key]
|
|
134
|
+
if (this[key] instanceof Struct) {
|
|
135
|
+
this[key].__internal__.removenode = true;
|
|
136
|
+
} else {
|
|
137
|
+
this[key] = REMOVE_NODE as any;
|
|
138
|
+
}
|
|
134
139
|
return this;
|
|
135
140
|
}
|
|
136
141
|
|
|
@@ -293,8 +298,13 @@ export class Struct {
|
|
|
293
298
|
equalsOrColon = value instanceof Struct ? ":" : "=";
|
|
294
299
|
spaceOrNoSpace = value === "" ? "" : " ";
|
|
295
300
|
}
|
|
296
|
-
|
|
297
|
-
|
|
301
|
+
const renderedValue =
|
|
302
|
+
value instanceof Struct && value.__internal__.removenode
|
|
303
|
+
? REMOVE_NODE
|
|
304
|
+
: value;
|
|
305
|
+
return pad(
|
|
306
|
+
`${keyOrIndex}${equalsOrColon}${spaceOrNoSpace}${renderedValue}`,
|
|
307
|
+
);
|
|
298
308
|
})
|
|
299
309
|
.join("\n");
|
|
300
310
|
text += "\nstruct.end";
|
|
@@ -315,6 +325,7 @@ export class Refs implements DefaultEntries {
|
|
|
315
325
|
isArray?: boolean;
|
|
316
326
|
isRoot?: boolean;
|
|
317
327
|
useAsterisk?: boolean;
|
|
328
|
+
removenode?: boolean;
|
|
318
329
|
|
|
319
330
|
constructor(ref?: string | Refs) {
|
|
320
331
|
if (typeof ref === "string") {
|
package/Struct.test.mts
CHANGED
|
@@ -50,6 +50,11 @@ class BuyLimitations extends Struct {
|
|
|
50
50
|
});
|
|
51
51
|
"0" = "EItemType::Weapon";
|
|
52
52
|
"1" = "EItemType::Armor";
|
|
53
|
+
"2" = new Struct({
|
|
54
|
+
__internal__: {
|
|
55
|
+
removenode: true,
|
|
56
|
+
},
|
|
57
|
+
});
|
|
53
58
|
}
|
|
54
59
|
|
|
55
60
|
describe("Struct", () => {
|
|
@@ -69,6 +74,7 @@ struct.end`,
|
|
|
69
74
|
BuyLimitations : struct.begin
|
|
70
75
|
[0] = EItemType::Weapon
|
|
71
76
|
[1] = EItemType::Armor
|
|
77
|
+
[2] : removenode
|
|
72
78
|
struct.end
|
|
73
79
|
struct.end
|
|
74
80
|
struct.end
|
|
@@ -270,7 +276,7 @@ struct.end`;
|
|
|
270
276
|
"EItemType::Artifact",
|
|
271
277
|
undefined,
|
|
272
278
|
);
|
|
273
|
-
expect(a.TradeGenerators[0].BuyLimitations[
|
|
279
|
+
expect(a.TradeGenerators[0].BuyLimitations[3]).toBe(
|
|
274
280
|
"EItemType::Artifact",
|
|
275
281
|
);
|
|
276
282
|
});
|
|
@@ -352,6 +358,11 @@ struct.end`;
|
|
|
352
358
|
__internal__: { rawName: "BuyLimitations", isArray: true },
|
|
353
359
|
"0": "EItemType::Weapon",
|
|
354
360
|
"1": "EItemType::Armor",
|
|
361
|
+
"2": {
|
|
362
|
+
__internal__: {
|
|
363
|
+
removenode: true,
|
|
364
|
+
},
|
|
365
|
+
},
|
|
355
366
|
},
|
|
356
367
|
},
|
|
357
368
|
},
|