1.0.0 • Published 6 years ago
sync-scandir v1.0.0
#Sync Scandir
##Recursive method to scan a dir for all items
The simple example to use minimal task, sync-scandir recovery all items of way recursive in a directory, return result sync
const scandir = require('sync-scandir').scan;
var items = scandir('path/to/dir');
console.log(items);
The sync-scandir function allow pass second parameter, a filter function to recive a argument with some detail of current item, for determine if is valid
const scandir = require('sync-scandir').scan;
var items = scandir('path/to/dir',function(stats){
if(stats.isFile())
return true;
else
return false;
});
console.log(items);
Have options the use other function, for example:
const scandir = require('sync-scandir').scanStat;
var items = scandir('path/to/dir');
console.log(items);
//return array with objects of details
//fields: filename,isFile,isDirectory,path
If want know about this module, make a test
npm test
And Review code in test.js
1.0.0
6 years ago