twalker
v0.0.6
Published
List files grouped by type, asynchronously.
Downloads
8
Maintainers
Readme
twalker
List files grouped by type, asynchronously. twalker is based in walk, a nodejs walk implementation.
Install
$ npm install --save twalker
Usage
var twalker = require('twalker');
var walk = twalker('/home/me', {
Images: ['jpg', 'png', 'gif', 'icon'],
Documents: ['doc', 'docx', 'txt', 'pdf', 'xls', 'xlsx']
});
walk.on('file', function (fileStats) {
//do something: calculate disk usage, list file names by type, etc.
//fileStats.metaType: 'Images', 'Documents'
});
walk.on('end', function () {
console.log('Done.')
})
If the types
parameter is null, it uses a default type definition, that can be accessed by twalker.metaTypes
property.
API
twalker(baseDir, types)
baseDir
Required
Type: string
The base directory where it walks from.
types
Optional
Type: JSON
List of files extensions grouped by type.
License
MIT © Danilo Sampaio