index.js
function emit (str) {
    const nwState = emit._events[emit._state][str]
    if (!reach(emit._state, nwState, emit._graph)) {
      const err = 'invalid transition: ' + emit._state + ' -> ' + str
      return emitter.emit('error', err)
    }

    const leaveEv = emit._state + ':leave'
    const enterEv = nwState + ':enter'

    if (!emit._state) return enter()
    return leave()

    function leave () {
      if (!emitter._events[leaveEv]) enter()
      else emitter.emit(leaveEv, enter)
    }

    function enter () {
      if (!emitter._events[enterEv]) done()
      else emitter.emit(enterEv, done)
    }

    function done () {
      emit._state = nwState
      emitter.emit(nwState)
      emitter.emit('done')
    }
  }
function emit (str) {
    const nwState = emit._events[emit._state][str]
    if (!reach(emit._state, nwState, emit._graph)) {
      const err = 'invalid transition: ' + emit._state + ' -> ' + str
      return emitter.emit('error', err)
    }

    const leaveEv = emit._state + ':leave'
    const enterEv = nwState + ':enter'

    if (!emit._state) return enter()
    return leave()

    function leave () {
      if (!emitter._events[leaveEv]) enter()
      else emitter.emit(leaveEv, enter)
    }

    function enter () {
      if (!emitter._events[enterEv]) done()
      else emitter.emit(enterEv, done)
    }

    function done () {
      emit._state = nwState
      emitter.emit(nwState)
      emitter.emit('done')
    }
  }
function emit ( str ) { const nwState = emit . _events [ emit . _state ] [ str ] if ( ! reach ( emit . _state , nwState , emit . _graph ) ) { const err = 'invalid transition: ' + emit . _state + ' -> ' + str return emitter . emit ( 'error' , err ) } const leaveEv = emit . _state + ':leave' const enterEv = nwState + ':enter' if ( ! emit . _state ) return enter ( ) return leave ( ) function leave ( ) { if ( ! emitter . _events [ leaveEv ] ) enter ( ) else emitter . emit ( leaveEv , enter ) } function enter ( ) { if ( ! emitter . _events [ enterEv ] ) done ( ) else emitter . emit ( enterEv , done ) } function done ( ) { emit . _state = nwState emitter . emit ( nwState ) emitter . emit ( 'done' ) } }
change the state str -> null
change the state str - > null