ンンンパ

1年間無職だった

vue-routerのroutesを全部出すやつ

だいたい見れる。

log(dig(router))
function digState (state, path = []) {
  state.nextStates.forEach((nextState) => {
    if (nextState.handlers) {
      nextState.handlers.forEach((handler) => path.push(handler))
    }
    if (nextState.charSpec.validChars) {
      digState(nextState, path)
    }
  })

  return path
}

function digNames (names, path = []) {
  for (let name in names) {
    router._recognizer.names[name].handlers.forEach((handler) => path.push(handler))
  }
}

function dig (router, path = []) {
  digState(router._recognizer.rootState, path)
  digNames(router._recognizer.names, path)

  return path
}

function log (path) {
  let logged = {}
  let logs = []
  path.forEach((hh) => {
    let h = hh.handler
    if (logged[h.fullPath]) {
      return
    }
    if (h.name) {
      logs.push(['/' + h.name, '=>', h.fullPath].join(' '))
    } else {
      logs.push(h.fullPath)
    }
    logged[h.fullPath] = true
  })

  logs.sort().forEach((l) => console.log(l))
}