vi-directory-loader
v1.1.0
Published
A loader to load files under a certain directory
Downloads
3
Maintainers
Readme
vi-directory-loader
A tool to find all files under a certain directory. The scan result files are organized in a tree just as they are in file system.
usage
const load = require('vi-directory-loader');
const directory = load('./foo');
/*
directory => {
'name': 'foo',
'type': 'DIRECTORY',
'files': Map{
'a': { 'name': 'a', ...},
'b': { 'name': 'b', ...},
...
}
}
*/
.filter() and .each()
Apply handler for every file and directory in the target.
const dectory1 = directory.filter(file => file.type !== file.File.TYPE_DIRECTORY && file.name != ''a');
directory.each(file => console.log(file.name));
.toTree()
Map all files into a tree, file name as the key and path (by default) as the value
const tree = directory.toTree();
/*
directory => {
'a': 'xxx',
'b': 'xxx',
'c': Map{
'd': 'xxx',
'e': 'xxx',
...
}
}
*/