find-promise

1.0.2 • Public • Published

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)

Readme

Keywords

Package Sidebar

Install

npm i find-promise

Weekly Downloads

46

Version

1.0.2

License

MIT

Last publish

Collaborators

  • eduardorfs