jssm 5.141.3 → 5.141.4

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/README.md CHANGED
@@ -18,10 +18,10 @@ Please edit the file it's derived from, instead: `./src/md/readme_base.md`
18
18
 
19
19
 
20
20
 
21
- * Generated for version 5.141.3 at 6/2/2026, 9:10:12 AM
21
+ * Generated for version 5.141.4 at 6/2/2026, 10:32:57 AM
22
22
 
23
23
  -->
24
- # jssm 5.141.3
24
+ # jssm 5.141.4
25
25
 
26
26
  [**Try the live editor**](https://stonecypher.github.io/jssm-viz-demo/graph_explorer.html) ·
27
27
  [Documentation](https://stonecypher.github.io/jssm/docs/) ·
@@ -281,7 +281,7 @@ That decision shows up everywhere downstream:
281
281
  or run `npm run benny` against your own machine.
282
282
 
283
283
  - **More thoroughly tested than any other JavaScript state-machine
284
- library.** 6,482 tests at 100.0% line coverage
284
+ library.** 6,484 tests at 100.0% line coverage
285
285
  ([report](https://coveralls.io/github/StoneCypher/jssm)), plus
286
286
  fuzz testing via `fast-check`, with parser test data across ten natural
287
287
  languages and Emoji.
@@ -414,11 +414,11 @@ If your contribution is missing here, please open an issue.
414
414
 
415
415
  <br/>
416
416
 
417
- ***6,482 tests***, run 57,269 times.
417
+ ***6,484 tests***, run 57,271 times.
418
418
 
419
- - 5,969 specs with 100.0% coverage
419
+ - 5,971 specs with 100.0% coverage
420
420
  - 513 fuzz tests with 3.4% coverage
421
- - 5,566 TypeScript lines - 1.2 tests per line, 10.3 generated tests per line
421
+ - 5,573 TypeScript lines - 1.2 tests per line, 10.3 generated tests per line
422
422
 
423
423
  [![Actions Status](https://github.com/StoneCypher/jssm/workflows/Node%20CI/badge.svg)](https://github.com/StoneCypher/jssm/actions)
424
424
  [![NPM version](https://img.shields.io/npm/v/jssm.svg)](https://www.npmjs.com/package/jssm)
@@ -21327,7 +21327,7 @@ var constants = /*#__PURE__*/Object.freeze({
21327
21327
  * Useful for runtime diagnostics and for embedding in serialized machine
21328
21328
  * snapshots so that deserializers can detect version-skew.
21329
21329
  */
21330
- const version = "5.141.3";
21330
+ const version = "5.141.4";
21331
21331
 
21332
21332
  // whargarbl lots of these return arrays could/should be sets
21333
21333
  const { state_name_chars, state_name_first_chars, action_label_chars } = constants;
@@ -21643,6 +21643,11 @@ class Machine {
21643
21643
  this._state_labels.set(key, labelled[0].value);
21644
21644
  }
21645
21645
  });
21646
+ // O(1) duplicate-edge guard for the construction loop below: from -> Set<to>.
21647
+ // Keyed by source state; mirrors each state's `to` array with constant-time
21648
+ // membership so the dedup check is O(1) per edge rather than an O(out-degree)
21649
+ // array scan (which made construction O(V*E) on dense graphs). #673
21650
+ const seen_edges = new Map();
21646
21651
  // walk the transitions
21647
21652
  transitions.map((tr) => {
21648
21653
  if (tr.from === undefined) {
@@ -21662,11 +21667,20 @@ class Machine {
21662
21667
  if (!(this._states.has(tr.to))) {
21663
21668
  this._new_state(cursor_to);
21664
21669
  }
21665
- // guard against existing connections being re-added
21666
- if (cursor_from.to.includes(tr.to)) {
21670
+ // guard against existing connections being re-added — O(1) via the
21671
+ // from -> Set<to> index instead of an O(out-degree) `cursor_from.to`
21672
+ // array scan. Behaviour is identical: the same duplicate (from, to)
21673
+ // pair throws the same JssmError. #673
21674
+ let seen_to = seen_edges.get(tr.from);
21675
+ if (seen_to === undefined) {
21676
+ seen_to = new Set();
21677
+ seen_edges.set(tr.from, seen_to);
21678
+ }
21679
+ if (seen_to.has(tr.to)) {
21667
21680
  throw new JssmError(this, `already has ${JSON.stringify(tr.from)} to ${JSON.stringify(tr.to)}`);
21668
21681
  }
21669
21682
  else {
21683
+ seen_to.add(tr.to);
21670
21684
  cursor_from.to.push(tr.to);
21671
21685
  cursor_to.from.push(tr.from);
21672
21686
  }
package/dist/cdn/viz.js CHANGED
@@ -21352,7 +21352,7 @@ var constants = /*#__PURE__*/Object.freeze({
21352
21352
  * Useful for runtime diagnostics and for embedding in serialized machine
21353
21353
  * snapshots so that deserializers can detect version-skew.
21354
21354
  */
21355
- const version = "5.141.3";
21355
+ const version = "5.141.4";
21356
21356
 
21357
21357
  // whargarbl lots of these return arrays could/should be sets
21358
21358
  const { state_name_chars, state_name_first_chars, action_label_chars } = constants;
@@ -21668,6 +21668,11 @@ class Machine {
21668
21668
  this._state_labels.set(key, labelled[0].value);
21669
21669
  }
21670
21670
  });
21671
+ // O(1) duplicate-edge guard for the construction loop below: from -> Set<to>.
21672
+ // Keyed by source state; mirrors each state's `to` array with constant-time
21673
+ // membership so the dedup check is O(1) per edge rather than an O(out-degree)
21674
+ // array scan (which made construction O(V*E) on dense graphs). #673
21675
+ const seen_edges = new Map();
21671
21676
  // walk the transitions
21672
21677
  transitions.map((tr) => {
21673
21678
  if (tr.from === undefined) {
@@ -21687,11 +21692,20 @@ class Machine {
21687
21692
  if (!(this._states.has(tr.to))) {
21688
21693
  this._new_state(cursor_to);
21689
21694
  }
21690
- // guard against existing connections being re-added
21691
- if (cursor_from.to.includes(tr.to)) {
21695
+ // guard against existing connections being re-added — O(1) via the
21696
+ // from -> Set<to> index instead of an O(out-degree) `cursor_from.to`
21697
+ // array scan. Behaviour is identical: the same duplicate (from, to)
21698
+ // pair throws the same JssmError. #673
21699
+ let seen_to = seen_edges.get(tr.from);
21700
+ if (seen_to === undefined) {
21701
+ seen_to = new Set();
21702
+ seen_edges.set(tr.from, seen_to);
21703
+ }
21704
+ if (seen_to.has(tr.to)) {
21692
21705
  throw new JssmError(this, `already has ${JSON.stringify(tr.from)} to ${JSON.stringify(tr.to)}`);
21693
21706
  }
21694
21707
  else {
21708
+ seen_to.add(tr.to);
21695
21709
  cursor_from.to.push(tr.to);
21696
21710
  cursor_to.from.push(tr.from);
21697
21711
  }