s2cfgtojson 3.2.9 → 3.2.10
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 -7
- package/package.json +1 -1
package/Struct.mts
CHANGED
|
@@ -122,16 +122,20 @@ export class Struct {
|
|
|
122
122
|
* Filters the struct entries based on a callback function. Returns a copy.
|
|
123
123
|
* @param callback
|
|
124
124
|
*/
|
|
125
|
-
filter<
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
filter<
|
|
126
|
+
K extends Exclude<keyof this, Internal>,
|
|
127
|
+
V extends (typeof this)[K],
|
|
128
|
+
S extends [K, V],
|
|
129
|
+
>(
|
|
130
|
+
callback: (value: [K, V], index: number, array: [K, V][]) => value is S,
|
|
131
|
+
): Record<K, V> & Struct {
|
|
128
132
|
const clone = this.clone();
|
|
129
|
-
clone.entries().forEach((
|
|
130
|
-
if (!callback(
|
|
131
|
-
delete clone[
|
|
133
|
+
clone.entries().forEach((entry, i, arr) => {
|
|
134
|
+
if (!callback(entry as any, i, arr as any)) {
|
|
135
|
+
delete clone[entry[0]];
|
|
132
136
|
}
|
|
133
137
|
});
|
|
134
|
-
return clone;
|
|
138
|
+
return clone as any;
|
|
135
139
|
}
|
|
136
140
|
|
|
137
141
|
/**
|