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.
Files changed (2) hide show
  1. package/Struct.mts +11 -10
  2. 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<K extends Exclude<keyof this, Internal>, V extends (typeof this)[K]>(
126
- callback: ([key, value]: [K, V], i: number, arr: [K, V][]) => boolean,
127
- ): Partial<this> & Struct {
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(([key, value], i, arr) => {
130
- if (!callback([key as K, value as V], i, arr as any)) {
131
- delete clone[key];
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
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "s2cfgtojson",
3
- "version": "3.2.9",
3
+ "version": "3.2.11",
4
4
  "description": "Converts Stalker 2 Cfg file into POJOs",
5
5
  "keywords": [
6
6
  "stalker",