s2cfgtojson 1.0.1 → 1.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.
- package/Struct.mts +5 -5
- package/package.json +1 -1
package/Struct.mts
CHANGED
|
@@ -68,7 +68,9 @@ export abstract class Struct<T extends Entries = {}> {
|
|
|
68
68
|
if (Struct.isNumber(Struct.extractKeyFromBrackets(name))) {
|
|
69
69
|
return `_${name.match(/\[(\d+)]/)[1]}`; // Special case for indexed structs
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
const replacer = (text: string) =>
|
|
72
|
+
text.replace(/\W/g, "_").replace(/_+/g, "_").replace(/^_/, "");
|
|
73
|
+
return `${replacer(name[0]).replace(/\d/, "")}${replacer(name.slice(1))}`;
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
static createDynamicClass = (name: string): new () => Struct =>
|
|
@@ -76,7 +78,7 @@ export abstract class Struct<T extends Entries = {}> {
|
|
|
76
78
|
|
|
77
79
|
toString(): string {
|
|
78
80
|
let text: string;
|
|
79
|
-
text = this.isRoot ? `${
|
|
81
|
+
text = this.isRoot ? `${this._id} : ` : "";
|
|
80
82
|
text += "struct.begin";
|
|
81
83
|
const refs = ["refurl", "refkey", "bskipref"]
|
|
82
84
|
.map((k) => [k, this[k]])
|
|
@@ -158,9 +160,7 @@ export abstract class Struct<T extends Entries = {}> {
|
|
|
158
160
|
let name = Struct.parseStructName(match[1].trim());
|
|
159
161
|
|
|
160
162
|
const dummy = new (Struct.createDynamicClass(name))();
|
|
161
|
-
|
|
162
|
-
dummy._id = name;
|
|
163
|
-
}
|
|
163
|
+
dummy._id = match[1];
|
|
164
164
|
if (match[3]) {
|
|
165
165
|
const refs = match[3]
|
|
166
166
|
.split(";")
|