1.0.2 • Published 8 years ago
find-promise v1.0.2
#find
Find files or directories by name. Using promises
Installation
$ npm install --save find-promise
Examples
Find all files in current directory.
var find = require('find-promise');
find.file(__dirname).then(function(files) {
console.log(files.length);
})
Filter by regular expression.
find.file(/\.js$/, __dirname.then(function(files) {
console.log(files.length);
})
Features
- Recursively search each sub-directories
- Asynchronously or synchronously
- Filtering by regular expression or string comparing
API
.file(pattern, root, callback)
find.file(__dirname).then(function(files) {
//
})
.dir(pattern, root, callback)
find.dir(__dirname).then(function(dirs) {
//
})
.eachfile(pattern, root, action)
find.eachfile(__dirname, function(file) {
//
}).then(onEnd)
.eachdir(pattern, root, action)
find.eachdir(__dirname, function(dir) {
//
}).then(onEnd)
.fileSync(pattern, root)
var files = find.fileSync(__dirname);
.dirSync(pattern, root)
var dirs = find.dirSync(__dirname);
LICENSE
(MIT Licensed)