<commit_before>import store from '@/store/store'

export const createUniqueKey = () => Date.now().toString(36) + Math.random().toString(36).substring(2)

export function retrieveViewName (pos) {
  let viewName = ''
  if (store.state.history.length >= pos) {
    viewName = store.state.history[store.state.history.length - pos].name
  }
  return viewName
}

export function transformViewName (view) {
  view = view.toLowerCase()
  let count = 0
  for (let i = 1; i <= store.state.history.length; i++) {
    if (store.state.history[store.state.history.length - i].name.split('--')[0] === view) {
      count += 1
    }
  }
  if (store.state.isRouterEnabled) {
    return view
  } else {
    return view + '--' + count
  }
}

export function parseView (data) {
  let name
  let route
  let paramPath = ''
  let path
  if (typeof data === 'string') {
    name = transformViewName(data)
    route = { name }
    path = '/' + name
  } else {
    Object.keys(data.params).forEach(function (key) {
      paramPath += '/:' + key
    })
    name = transformViewName(data.name)
    route = { name, params: data.params }
    path = '/' + name + '' + paramPath
  }
  return {
    name,
    route,
    path
  }
}
<commit_msg>refactor(utils): refactor retrieveViewName, transformViewName and parseView methods<commit_after>import store from '@/store/store'

export const createUniqueKey = () => Date.now().toString(36) + Math.random().toString(36).substring(2)

export function retrieveViewName (pos) {
  if (store.state.history.length <= pos) {
    return ''
  }
  return store.state.history[store.state.history.length - pos].name
}

export function transformViewName (view) {
  view = view.toLowerCase()
  let count = 0

  if (!store.state.isRouterEnabled) {
    count = store.state.history.filter((historicView) => historicView.name.startsWith(view)).length
    view += '--' + count
  }
  return view
}

export function parseView (data) {
  const baseName = (typeof data === 'object') ? data.name : data
  const name = transformViewName(baseName)
  const route = { name, params: data.params }
  let path = '/' + name

  if (typeof data === 'object' && typeof data.params === 'object') {
    let paramPath = ''
    Object.keys(data.params).forEach(function (key) {
      paramPath += '/:' + key
    })
    path += paramPath
  }

  return {
    name,
    route,
    path
  }
}

{'fraction_non_alphanumeric': 0.1510791366906475, 'fraction_numerical': 0.006347862886161659, 'mean_word_length': 3.082901554404145, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2713189', 'n_tokens_mistral': 768, 'n_tokens_neox': 760, 'n_words': 178}