s2cfgtojson 3.2.9 → 3.2.11
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 +11 -10
- package/package.json +1 -1
package/Struct.mts
CHANGED
|
@@ -77,9 +77,6 @@ export class Struct {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
addNode(value: any, key?: string | number): this {
|
|
80
|
-
if (this.__internal__.isArray !== true) {
|
|
81
|
-
throw new Error("Cannot add node to non-array struct.");
|
|
82
|
-
}
|
|
83
80
|
if (key === undefined) {
|
|
84
81
|
const nextIndex = Object.keys(this)
|
|
85
82
|
.map((k) => parseInt(k))
|
|
@@ -122,16 +119,20 @@ export class Struct {
|
|
|
122
119
|
* Filters the struct entries based on a callback function. Returns a copy.
|
|
123
120
|
* @param callback
|
|
124
121
|
*/
|
|
125
|
-
filter<
|
|
126
|
-
|
|
127
|
-
|
|
122
|
+
filter<
|
|
123
|
+
K extends Exclude<keyof this, Internal>,
|
|
124
|
+
V extends (typeof this)[K],
|
|
125
|
+
S extends [K, V],
|
|
126
|
+
>(
|
|
127
|
+
callback: (value: [K, V], index: number, array: [K, V][]) => value is S,
|
|
128
|
+
): Record<K, V> & Struct {
|
|
128
129
|
const clone = this.clone();
|
|
129
|
-
clone.entries().forEach((
|
|
130
|
-
if (!callback(
|
|
131
|
-
delete clone[
|
|
130
|
+
clone.entries().forEach((entry, i, arr) => {
|
|
131
|
+
if (!callback(entry as any, i, arr as any)) {
|
|
132
|
+
delete clone[entry[0]];
|
|
132
133
|
}
|
|
133
134
|
});
|
|
134
|
-
return clone;
|
|
135
|
+
return clone as any;
|
|
135
136
|
}
|
|
136
137
|
|
|
137
138
|
/**
|