path-list-to-tree
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

path-list-to-tree

Converts a list of file paths into a tree structure.

Example

import pathListToTree from 'path-list-to-tree';
 
const filePaths = [
  '.gitignore',
  'README.md',
  'package.json',
  'src/index.ts',
  'tsconfig.json',
  'yarn-error.log',
  'yarn.lock'
];
 
console.log(pathListToTree(filePaths))
[
   {
      "name":".gitignore",
      "children":[
 
      ]
   },
   {
      "name":"README.md",
      "children":[
 
      ]
   },
   {
      "name":"package.json",
      "children":[
 
      ]
   },
   {
      "name":"src",
      "children":[
         {
            "name":"index.ts",
            "children":[
 
            ]
         }
      ]
   },
   {
      "name":"tsconfig.json",
      "children":[
 
      ]
   },
   {
      "name":"yarn-error.log",
      "children":[
 
      ]
   },
   {
      "name":"yarn.lock",
      "children":[
 
      ]
   }

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i path-list-to-tree

    Weekly Downloads

    68

    Version

    1.1.1

    License

    MIT

    Unpacked Size

    2.36 kB

    Total Files

    4

    Last publish

    Collaborators

    • pthm