Gathering detailed insights and metrics for @taoqf/javascript-state-machine
Gathering detailed insights and metrics for @taoqf/javascript-state-machine
Gathering detailed insights and metrics for @taoqf/javascript-state-machine
Gathering detailed insights and metrics for @taoqf/javascript-state-machine
A javascript finite state machine library
npm install @taoqf/javascript-state-machine
Typescript
Module System
Node Version
NPM Version
JavaScript (91.56%)
TypeScript (7.02%)
HTML (1.42%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
17 Stars
199 Commits
13 Forks
3 Watchers
2 Branches
1 Contributors
Updated on May 31, 2023
Latest Version
3.1.6
Package Id
@taoqf/javascript-state-machine@3.1.6
Unpacked Size
395.56 kB
Size
229.96 kB
File Count
61
NPM Version
7.3.0
Node Version
15.5.1
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
9
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.
值得注意的是VERSION 3.0 已经重写了。 现有2.x用户应该阅读升级指南.
In a browser:
1<script src='https://unpkg.com/@taoqf/javascript-state-machine'></script> 2<!-- or --> 3<script src='https://unpkg.com/@taoqf/javascript-state-machine/dist/state-machine.min.js'></script>
after downloading the source or the minified version
Using npm:
1 npm install --save-dev @taoqf/javascript-state-machine
In Node.js:
1 var StateMachine = require('@taoqf/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
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 2/27 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
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
Score
Last Scanned on 2025-06-30
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