src/Transition.js
function Transition(fromStateWithParams, toStateWithParams, paramsDiff, acc, router, logger) {
  let root = { root: null, inclusive: true }
  let enters
  let exits

  const fromState = fromStateWithParams && fromStateWithParams.state
  const toState = toStateWithParams.state
  const params = toStateWithParams.params
  const isUpdate = (fromState == toState)

  const transition = {
    from: fromState,
    to: toState,
    toParams: params,
    cancel,
    run,
    cancelled: false,
    currentState: fromState
  }

  // The first transition has no fromState.
  if (fromState)
    root = transitionRoot(fromState, toState, isUpdate, paramsDiff)

  exits = fromState ? transitionStates(fromState, root) : []
  enters = transitionStates(toState, root).reverse()

  function run() {
    startTransition(enters, exits, params, transition, isUpdate, acc, router, logger)
  }

  function cancel() {
    transition.cancelled = true
  }

  return transition
}
function Transition(fromStateWithParams, toStateWithParams, paramsDiff, acc, router, logger) {
  let root = { root: null, inclusive: true }
  let enters
  let exits

  const fromState = fromStateWithParams && fromStateWithParams.state
  const toState = toStateWithParams.state
  const params = toStateWithParams.params
  const isUpdate = (fromState == toState)

  const transition = {
    from: fromState,
    to: toState,
    toParams: params,
    cancel,
    run,
    cancelled: false,
    currentState: fromState
  }

  // The first transition has no fromState.
  if (fromState)
    root = transitionRoot(fromState, toState, isUpdate, paramsDiff)

  exits = fromState ? transitionStates(fromState, root) : []
  enters = transitionStates(toState, root).reverse()

  function run() {
    startTransition(enters, exits, params, transition, isUpdate, acc, router, logger)
  }

  function cancel() {
    transition.cancelled = true
  }

  return transition
}
/*
Create a new Transition instance.