List files grouped by type, asynchronously. twalker is based in walk, a nodejs walk implementation.
$ npm install --save twalker
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.
Required
Type: string
The base directory where it walks from.
Optional
Type: JSON
List of files extensions grouped by type.
MIT © Danilo Sampaio