Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-flatten-routes

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-flatten-routes

Get a flat routes array from your [`vue-router`](https://github.com/vuejs/vue-router) compatible routes. ## Install ``` npm install --save vue-flatten-routes ``` ## Usage ```js // Helpers import { flattenRoutes } from 'vue-flatten-routes'

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14
increased by16.67%
Maintainers
1
Weekly downloads
 
Created
Source

Vue-Flatten-Routes

Get a flat routes array from your vue-router compatible routes.

Install

npm install --save vue-flatten-routes

Usage

// Helpers
import { flattenRoutes } from 'vue-flatten-routes'

// Routes
const routes = [
  {
    name: 'foo',
    path: 'foo',
    children: [
      {
        name: 'foo-first-level-child',
        path: 'foo-first-level-child',
        children: [
          {
            path: 'foo-second-level-child',
            name: 'foo-second-level-child',
            children: [
              {
                path: 'foo-third-level-child',
                name: 'foo-third-level-child'
              }
            ]
          }
        ]
      },
      {
        name: 'foo-first-level-child-nd',
        path: 'foo-first-level-child-nd',
      }
    ]
  },
  {
    name: 'bar',
    path: 'bar'
  }
]

// Flatten
console.log(JSON.stringify(flattenRoutes(routes), null, 2))

/* Output:
[
  {
    "name": "foo",
    "path": "foo",
    "level": 0
  },
  {
    "name": "foo-first-level-child",
    "path": "foo-first-level-child",
    "level": 1
  },
  {
    "name": "foo-second-level-child",
    "path": "foo-second-level-child",
    "level": 2
  },
  {
    "name": "foo-third-level-child",
    "path": "foo-third-level-child",
    "level": 3
  },
  {
    "name": "foo-first-level-child-nd",
    "path": "foo-first-level-child-nd",
    "level": 1
  },
  {
    "name": "bar",
    "path": "bar",
    "level": 0
  }
]
*/

FAQs

Package last updated on 02 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc