dir-tree-obj
v0.0.1
Published
Create a JavaScript object representing the structure of a directory
Downloads
2
Readme
dir-tree-obj
Create a JavaScript object representing the structure of a directory
Installation
yarn add dir-tree-obj
Usage
Assume a directory named dir
with the following structure:
├── a.txt
├── b.txt
└── sub
├── a.js
├── a.txt
└── b.txt
import dirTreeObj from 'dir-tree-obj';
dirTreeObj('./dir');
/**
* Prints: {
'.': ['a.txt', 'b.txt'],
sub: {
'.': ['a.js', 'a.txt', 'b.txt'],
},
}
*/
Note: file names are always sorted.