Comments (4)
more than happy for you to send a PR with a toMermaid()
function that outputs the Mermaid state diagram as a string.
from typescript-fsm.
@bennycode use something like chatGPT to generate a Mermaid stateDiagram?
from typescript-fsm.
for example, i ask chat:
pls create a mermaid state diagram for the following state machine:
// these are the states and events for the door
enum States { closing = 0, closed, opening, opened, broken };
enum Events { open = 100, openComplete, close, closeComplete, break };
// lets define the transitions that will govern the state-machine
const transitions = [
/* fromState event toState callback */
t(States.closed, Events.opened, States.opening, onOpen),
t(States.opening, Events.openComplete, States.opened, justLog),
t(States.opened, Events.close, States.closing, onClose),
t(States.closing, Events.closeComplete, States.closed, justLog),
t(States.closed, Events.break, States.broken, justLog),
t(States.opened, Events.break, States.broken, justLog),
t(States.opening, Events.break, States.broken, justLog),
t(States.closing, Events.break, States.broken, justLog),
];
This is the answer I get:
stateDiagram
[*] --> closed
closed --> opening : open
opening --> opened : openComplete
opened --> closing : close
closing --> closed : closeComplete
closed --> broken : break
opened --> broken : break
opening --> broken : break
closing --> broken : break
from typescript-fsm.
That's cool! Preferably I would like to get Markdown code (using Mermaid syntax) directly from your library. With using TypeScript for code analysis this should be possible and would be a kick-ass feature for this lib! :D
stateDiagram
[*] --> closed
closed --> opening : open
opening --> opened : openComplete
opened --> closing : close
closing --> closed : closeComplete
closed --> broken : break
opened --> broken : break
opening --> broken : break
closing --> broken : break
from typescript-fsm.
Related Issues (8)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typescript-fsm.