@peter.naydenov/fsm 4.0.2 → 5.0.0
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/Changelog.md +90 -0
- package/LICENSE +21 -0
- package/Migration.guide.md +86 -0
- package/README.md +96 -173
- package/README_v.4.x.x.md +491 -0
- package/blueprint.md +22 -0
- package/coverage/lcov-report/index.html +1 -1
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/index.js.html +1 -1
- package/coverage/lcov-report/src/methods/_getChain.js.html +1 -1
- package/coverage/lcov-report/src/methods/_onUpdateTask.js.html +1 -1
- package/coverage/lcov-report/src/methods/_setTransitions.js.html +1 -1
- package/coverage/lcov-report/src/methods/_transit.js.html +1 -1
- package/coverage/lcov-report/src/methods/_triggerCacheUpdate.js.html +1 -1
- package/coverage/lcov-report/src/methods/_updateStep.js.html +1 -1
- package/coverage/lcov-report/src/methods/_warn.js.html +1 -1
- package/coverage/lcov-report/src/methods/exportState.js.html +1 -1
- package/coverage/lcov-report/src/methods/getState.js.html +1 -1
- package/coverage/lcov-report/src/methods/ignoreCacheUpdates.js.html +1 -1
- package/coverage/lcov-report/src/methods/importState.js.html +1 -1
- package/coverage/lcov-report/src/methods/index.html +1 -1
- package/coverage/lcov-report/src/methods/index.js.html +1 -1
- package/coverage/lcov-report/src/methods/off.js.html +1 -1
- package/coverage/lcov-report/src/methods/on.js.html +1 -1
- package/coverage/lcov-report/src/methods/reset.js.html +1 -1
- package/coverage/lcov-report/src/methods/setDependencies.js.html +1 -1
- package/coverage/lcov-report/src/methods/update.js.html +1 -1
- package/coverage/tmp/coverage-51040-1691437648869-0.json +1 -0
- package/package.json +8 -7
- package/src/main.js +75 -0
- package/src/methods/_getChain.js +3 -2
- package/src/methods/_onUpdateTask.js +1 -1
- package/src/methods/_setTransitions.js +3 -3
- package/src/methods/_transit.js +7 -4
- package/src/methods/_triggerCacheUpdate.js +2 -0
- package/src/methods/_updateStateData.js +43 -0
- package/src/methods/_updateStep.js +10 -13
- package/src/methods/_warn.js +1 -1
- package/src/methods/exportState.js +5 -8
- package/src/methods/extractList.js +26 -0
- package/src/methods/getDependencies.js +10 -0
- package/src/methods/importState.js +3 -1
- package/src/methods/index.js +23 -15
- package/src/methods/reset.js +3 -2
- package/src/methods/setDependencies.js +1 -1
- package/src/methods/update.js +14 -4
- package/src/queryStateUpdate.js +38 -0
- package/coverage/tmp/coverage-29775-1668580484020-0.json +0 -1
- package/src/index.js +0 -41
package/src/index.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import walk from '@peter.naydenov/walk'
|
|
2
|
-
import methods from './methods/index.js'
|
|
3
|
-
import askForPromise from 'ask-for-promise'
|
|
4
|
-
|
|
5
|
-
const MISSING_STATE = 'N/A';
|
|
6
|
-
|
|
7
|
-
function Fsm ({init, table, stateData, debug }, lib={} ) {
|
|
8
|
-
const fsm = this;
|
|
9
|
-
|
|
10
|
-
fsm.state = init || MISSING_STATE
|
|
11
|
-
fsm.initialState = init || MISSING_STATE
|
|
12
|
-
fsm.lock = false // switch 'ON' during transition in progress. Write other updates in cache.
|
|
13
|
-
fsm.cache = [] // cached 'update' commands
|
|
14
|
-
fsm.askForPromise = askForPromise
|
|
15
|
-
|
|
16
|
-
fsm.stateData = { ...stateData }
|
|
17
|
-
fsm.initialStateData = Object.freeze ({ ...stateData })
|
|
18
|
-
fsm.dependencies = { walk, askForPromise }
|
|
19
|
-
fsm.callback = {
|
|
20
|
-
update : []
|
|
21
|
-
, transition : []
|
|
22
|
-
, positive : []
|
|
23
|
-
, negative : []
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
for ( let k in methods ) {
|
|
27
|
-
fsm[k] = methods[k](fsm)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const {transitions, nextState, chainActions } = fsm._setTransitions ( table, lib );
|
|
31
|
-
if ( debug ) fsm._warn ( transitions )
|
|
32
|
-
fsm.transitions = transitions
|
|
33
|
-
fsm.nextState = nextState
|
|
34
|
-
fsm.chainActions = chainActions
|
|
35
|
-
} // Fsm func.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
export default Fsm
|
|
40
|
-
|
|
41
|
-
|