nv-state-basic
v1.0.3
Published
nv-state-basic ======================== - nv-state-basic for nest-state-machine-definition mgmt
Downloads
1
Readme
nv-state-basic
- nv-state-basic for nest-state-machine-definition mgmt
install
- npm install nv-state-basic
usage
const {load_from_json} = require("nv-state-basic");
example
var STATE = [
'pending',
'settled', [
'resolved',
'rejected'
]
]
var rt = load_from_json('promise',STATE)
> rt
State [
promise
pending
settled
resolved
rejected
] {
T: 'promise',
A: {}
}
> rt.nmap()
{
'0': 'promise',
'1': 'promise/pending',
'2': 'promise/settled',
'3': 'promise/settled/resolved',
'4': 'promise/settled/rejected',
promise: 0,
'promise/pending': 1,
'promise/settled': 2,
'promise/settled/resolved': 3,
'promise/settled/rejected': 4
}
> rt.json()
[ 'pending', 'settled', [ 'resolved', 'rejected' ] ]
>
> rt.$fstch_
State [
pending
] { T: 'pending', A: {} }
>
> rt.pending
State [
pending
] { T: 'pending', A: {} }
>
> rt
State [
promise
pending
settled
resolved
rejected
] {
T: 'promise',
A: {}
}
> rt.pending
State [
pending
] { T: 'pending', A: {} }
>
> rt.settled
State [
settled
resolved
rejected
] {
T: 'settled',
A: {}
}
> rt.settled.resolved
State [
resolved
] { T: 'resolved', A: {} }
>
> rt.settled.resolved.$parent_
State [
settled
resolved
rejected
] {
T: 'settled',
A: {}
}
>
> rt.settled.resolved.pl_
[ 'promise', 'settled', 'resolved' ]
>
> rt.settled.resolved.path_
'promise/settled/resolved'
>
var STATE = [
'ready',
'pending',
'settled', [
'resolved',
'rejected'
],
'stopped',[
'paused',
'impossible'
]
]
var rt = load_from_json('event',STATE)
> rt.slct_
rt.slct_impossible rt.slct_paused rt.slct_pending rt.slct_ready rt.slct_rejected
rt.slct_resolved
rt.slct_rejected()
> rt
State [
event
ready
pending
settled
resolved
rejected
stopped
paused
impossible
] {
T: 'event',
A: {},
curr_: 'rejected'
}
>rt.is_
rt.is_impossible rt.is_paused rt.is_pending rt.is_ready rt.is_rejected rt.is_resolved
rt.is_settled rt.is_stopped
> rt.is_settled()
true
> rt.is_rejected()
true
> rt.is_resolved()
false
> rt.is_stopped()
false
> rt.is_pending()
false
> rt.is_ready()
false
>
> rt.slct_resolved()
undefined
> rt
State [
event
ready
pending
settled
resolved
rejected
stopped
paused
impossible
] {
T: 'event',
A: {},
curr_: 'resolved'
}
> rt.is_settled()
true
> rt.is_resolved()
true
> rt.is_rejected()
false
>
METHODS
API
- load_from_json(j)
LICENSE
- ISC