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":[
 
      ]
   }

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.1.1
    86
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.1.1
    86
  • 1.1.0
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i path-list-to-tree

Weekly Downloads

86

Version

1.1.1

License

MIT

Unpacked Size

2.36 kB

Total Files

4

Last publish

Collaborators

  • pthm