Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/eknkc/walkfs

Recursively walk over filesystem directories.
https://github.com/eknkc/walkfs

Last synced: 9 days ago
JSON representation

Recursively walk over filesystem directories.

Awesome Lists containing this project

README

        

# walkfs
Recursively walk over filesystem directories.

## install
```
npm install walkfs
```

## usage
### iterator mode
#### walkfs(directory, iterator, [oncomplete])

```
var walkfs = require('walkfs');

walkfs('/tmp', function(entry, next) {
console.log(entry);
// {
// type: 'file|directory|link',
// path: ,
// stat:
// }
next();
}, function(err) {
console.log('completed');
})
```

### event emitter mode
#### walkfs(directory).on('file|link|directory|path|error|end', handler)

```
var walkfs = require('walkfs');
walkfs('/tmp')
.on('path', function(entry) {
// emitted for all directories, links and files with the entry object specified above.
})
.on('file', function(entry) {
// emitted for all files with the entry object specified above.
})
.on('link', function(entry) {
// emitted for all links with the entry object specified above.
})
.on('directory', function(entry) {
// emitted for all directories with the entry object specified above.
})
.on('error', function(err) {
console.log('error: ' + err.message);
})
.on('end', function() {
console.log('completed');
})
```

## license
MIT