Gathering detailed insights and metrics for javascript-state-machine
Gathering detailed insights and metrics for javascript-state-machine
Gathering detailed insights and metrics for javascript-state-machine
Gathering detailed insights and metrics for javascript-state-machine
A javascript finite state machine library
npm install javascript-state-machine
99.8
Supply Chain
100
Quality
75.4
Maintenance
100
Vulnerability
100
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
8,711 Stars
164 Commits
967 Forks
261 Watching
3 Branches
11 Contributors
Updated on 28 Nov 2024
JavaScript (99.56%)
HTML (0.44%)
Cumulative downloads
Total Downloads
Last day
-4.8%
23,271
Compared to previous day
Last week
1.2%
130,862
Compared to previous week
Last month
6%
564,211
Compared to previous month
Last year
-1.2%
6,045,811
Compared to previous year
A library for finite state machines.
VERSION 3.0 Is a significant rewrite from earlier versions. Existing 2.x users should be sure to read the Upgrade Guide.
In a browser:
1 <script src='state-machine.js'></script>
after downloading the source or the minified version
Using npm:
1 npm install --save-dev javascript-state-machine
In Node.js:
1 var StateMachine = require('javascript-state-machine');
A state machine can be constructed using:
1 var fsm = new StateMachine({ 2 init: 'solid', 3 transitions: [ 4 { name: 'melt', from: 'solid', to: 'liquid' }, 5 { name: 'freeze', from: 'liquid', to: 'solid' }, 6 { name: 'vaporize', from: 'liquid', to: 'gas' }, 7 { name: 'condense', from: 'gas', to: 'liquid' } 8 ], 9 methods: { 10 onMelt: function() { console.log('I melted') }, 11 onFreeze: function() { console.log('I froze') }, 12 onVaporize: function() { console.log('I vaporized') }, 13 onCondense: function() { console.log('I condensed') } 14 } 15 });
... which creates an object with a current state property:
fsm.state
... methods to transition to a different state:
fsm.melt()
fsm.freeze()
fsm.vaporize()
fsm.condense()
... observer methods called automatically during the lifecycle of a transition:
onMelt()
onFreeze()
onVaporize()
onCondense()
... along with the following helper methods:
fsm.is(s)
- return true if state s
is the current statefsm.can(t)
- return true if transition t
can occur from the current statefsm.cannot(t)
- return true if transition t
cannot occur from the current statefsm.transitions()
- return list of transitions that are allowed from the current statefsm.allTransitions()
- return list of all possible transitionsfsm.allStates()
- return list of all possible statesA state machine consists of a set of States
A state machine changes state by using Transitions
A state machine can perform actions during a transition by observing Lifecycle Events
A state machine can also have arbitrary Data and Methods.
Multiple instances of a state machine can be created using a State Machine Factory.
Read more about
You can Contribute to this project with issues or pull requests.
See RELEASE NOTES file.
See MIT LICENSE file.
If you have any ideas, feedback, requests or bug reports, you can reach me at jake@codeincomplete.com, or via my website: Code inComplete
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 4/27 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
77 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More