Skip to content

Commit

Permalink
modified creation of edge key to use JSON.stringify since cond value …
Browse files Browse the repository at this point in the history
…can be an object.
  • Loading branch information
coolwr committed Oct 4, 2019
1 parent 4688831 commit 80c9e20
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sierralabs/xstate-viz",
"version": "0.2.2",
"version": "0.2.3",
"description": "Visualizer for XState.",
"main": "lib/index.js",
"scripts": {
Expand Down
4 changes: 3 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ export function getEventDelay(event: string): string | number | false {
}

export function serializeEdge(edge: Edge<any, any>): string {
const cond = edge.cond ? `[${edge.cond.toString().replace(/\n/g, '')}]` : '';
// PREVIOUS: const cond = edge.cond ? `[${edge.cond.toString().replace(/\n/g, '')}]` : '';
// NOTE: edge.cond can be an object so use JSON.stringify()
const cond = edge.cond ? `[${JSON.stringify(edge.cond)}]` : '';
return `${edge.source.id}:${edge.event}${cond}->${edge.target.id}`;
}

Expand Down

0 comments on commit 80c9e20

Please sign in to comment.