spice-js 2.7.4 → 2.7.5

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.
@@ -1894,11 +1894,19 @@ class SpiceModel {
1894
1894
 
1895
1895
  var modifiers = ((_this18$_serializers = _this18[_serializers]) == null ? void 0 : (_this18$_serializers$ = _this18$_serializers[type]) == null ? void 0 : _this18$_serializers$.modifiers) || [];
1896
1896
 
1897
- for (var modifier of modifiers) {
1897
+ for (var i = 0; i < modifiers.length; i++) {
1898
+ var modifier = modifiers[i];
1899
+
1898
1900
  try {
1899
- data = yield modifier(data, old_data, _this18[_ctx], _this18.type);
1901
+ var result = yield modifier(data, old_data, _this18[_ctx], _this18.type); // Guard against modifiers that return undefined
1902
+
1903
+ if (result !== undefined) {
1904
+ data = result;
1905
+ } else {
1906
+ console.warn("Modifier #" + i + " for type=" + _this18.type + " returned undefined, keeping previous data");
1907
+ }
1900
1908
  } catch (error) {
1901
- console.error("Modifier error in do_serialize:", error.stack);
1909
+ console.error("Modifier error in do_serialize (type=" + _this18.type + ", modifier #" + i + "):", error instanceof Error ? error.stack : "Non-Error thrown: " + JSON.stringify(error));
1902
1910
  }
1903
1911
  } // Ensure data is always an array for consistent processing.
1904
1912
 
@@ -1957,7 +1965,7 @@ class SpiceModel {
1957
1965
 
1958
1966
  return yield doSerialize();
1959
1967
  } catch (error) {
1960
- console.error("Error in do_serialize:", error.stack);
1968
+ console.error("Error in do_serialize:", error instanceof Error ? error.stack : "Non-Error thrown: " + JSON.stringify(error));
1961
1969
  throw error;
1962
1970
  }
1963
1971
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spice-js",
3
- "version": "2.7.4",
3
+ "version": "2.7.5",
4
4
  "description": "spice",
5
5
  "main": "build/index.js",
6
6
  "repository": {
@@ -1678,11 +1678,25 @@ export default class SpiceModel {
1678
1678
 
1679
1679
  // Cache the modifiers lookup for the specified type.
1680
1680
  const modifiers = this[_serializers]?.[type]?.modifiers || [];
1681
- for (const modifier of modifiers) {
1681
+ for (let i = 0; i < modifiers.length; i++) {
1682
+ const modifier = modifiers[i];
1682
1683
  try {
1683
- data = await modifier(data, old_data, this[_ctx], this.type);
1684
+ const result = await modifier(data, old_data, this[_ctx], this.type);
1685
+ // Guard against modifiers that return undefined
1686
+ if (result !== undefined) {
1687
+ data = result;
1688
+ } else {
1689
+ console.warn(
1690
+ `Modifier #${i} for type=${this.type} returned undefined, keeping previous data`
1691
+ );
1692
+ }
1684
1693
  } catch (error) {
1685
- console.error("Modifier error in do_serialize:", error.stack);
1694
+ console.error(
1695
+ `Modifier error in do_serialize (type=${this.type}, modifier #${i}):`,
1696
+ error instanceof Error ?
1697
+ error.stack
1698
+ : `Non-Error thrown: ${JSON.stringify(error)}`
1699
+ );
1686
1700
  }
1687
1701
  }
1688
1702
 
@@ -1735,7 +1749,12 @@ export default class SpiceModel {
1735
1749
  }
1736
1750
  return await doSerialize();
1737
1751
  } catch (error) {
1738
- console.error("Error in do_serialize:", error.stack);
1752
+ console.error(
1753
+ "Error in do_serialize:",
1754
+ error instanceof Error ?
1755
+ error.stack
1756
+ : `Non-Error thrown: ${JSON.stringify(error)}`
1757
+ );
1739
1758
  throw error;
1740
1759
  }
1741
1760
  }