https://github.com/pthm/node-path-list-to-tree
Converts a list of file paths into a tree structure.
https://github.com/pthm/node-path-list-to-tree
Last synced: 8 months ago
JSON representation
Converts a list of file paths into a tree structure.
- Host: GitHub
- URL: https://github.com/pthm/node-path-list-to-tree
- Owner: pthm
- Created: 2018-04-16T15:25:25.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2020-06-08T13:17:47.000Z (about 6 years ago)
- Last Synced: 2025-09-23T23:51:29.643Z (9 months ago)
- Language: TypeScript
- Homepage:
- Size: 4.88 KB
- Stars: 13
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# path-list-to-tree
Converts a list of file paths into a tree structure.
## Example
```javascript
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))
```
```json
[
{
"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":[
]
}
```