1.0.2 • Published 4 years ago

nv-facutil-state v1.0.2

Weekly downloads
118
License
ISC
Repository
-
Last release
4 years ago

nv-facutil-state

  • nv-facutil-state for nest-state-machine-definition mgmt

install

  • npm install nv-facutil-state

usage

example

const {State,load_from_json} = require("nv-facutil-state")


var state = new State()
state.$add('init')
state.init.$add('key_open')
state.init.key_open.$add("quote_open")
state.init.$plset_dflt('val_open',"quote_open","hash")
state.init.$plset_dflt('val_open',"quote_open","ref")

state
> state
 {
  init: ‍ [init] {
    key_open: ‍ [key_open] { quote_open: ‍ [quote_open] {} },
    val_open: ‍ [val_open] { quote_open: [‍ [quote_open]] }
  }
}

>

> state.init.key_open.quote_open.$parent
 [key_open] { quote_open: ‍ [quote_open] {} }
>


state.init.$children
> state.init.$children
[
  ‍ [key_open] { quote_open: ‍ [quote_open] {} },
  ‍ [val_open] {
    quote_open: ‍ [quote_open] { hash: ‍ [hash] {}, ref: ‍ [ref] {} }
  }
]
>
> state.init.$deses
[
  ‍ [key_open] { quote_open: ‍ [quote_open] {} },
  ‍ [val_open] {
    quote_open: ‍ [quote_open] { hash: ‍ [hash] {}, ref: ‍ [ref] {} }
  },
  ‍ [quote_open] {},
  ‍ [quote_open] { hash: ‍ [hash] {}, ref: ‍ [ref] {} },
  ‍ [hash] {},
  ‍ [ref] {}
]
>



> state.init.key_open.quote_open.$is_child_state_of(state.init.key_open)
true
>
> state.init.key_open.quote_open.$is_child_state_of(state.init.val_open)
false
>

state.init.key_open.quote_open.$is_des_state_of(state.init)
true
>


var j = state.$json() 
/*
{
    "init": {
        "key_open": {
            "quote_open": {}
        },
        "val_open": {
            "quote_open": {
                "hash": {},
                "ref": {}
            }
        }
    }
}
*/


var state = load_from_json(j)
/*
 {
  init: ‍ [init] {
    key_open: ‍ [key_open] { quote_open: ‍ [quote_open] {} },
    val_open: ‍ [val_open] { quote_open: [‍ [quote_open]] }
  }
}
>
*/

METHODS

state.$add                  state.$ances                state.$children             state.$del
state.$deses                state.$disconn              state.$is_child_state_of    state.$is_des_state_of
state.$json                 state.$parent               state.$pl                   state.$pldel
state.$plget                state.$plset                state.$plset_dflt           

API

  • load_from_json(j)

LICENSE

  • ISC
1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago