0.3.1 • Published 5 years ago
node-yaff v0.3.1
node-yaff
Yet Another Files Finder in Node. Provide a unique way to walk through specific directories and find all matched files.
API
class Finder(dirs, extensions, ignore, native);
Finder.prototype.find: Promise;
Finder.findInNative(dirs, extensions, ignore, resolve, reject): void;
Finder.findInNode(dirs, extensions, ignore, resolve, reject): void;
dirs:Array|String|undefined
directories to be scanned. Defaults to '.'
extensions:Array|String|undefined
file extensions to be matched. Defaults to '*'
ignore:Function|undefined
ignore function that accept a filePath and decide whether ignore it or not
native: boolean|undefined
use shell or node logic
Usage
Currently node-yaff only used for programmatically.
example one
find all files in current working directory:
const Finder = require('node-yaff');
const f = new Finder(['./'], /* '*' also make sense */);
f.find().then(files => {
// all files
})
example two
find all js files in current working directory:
const Finder = require('node-yaff');
const f = new Finder(['./'], ['.js']);
f.find().then(files => {
// all js files
})
example three
find all files do not have special character:
const Finder = require('node-yaff');
const f = new Finder(['./'], '*', p => /s$/.test(p));
f.find().then(files => {
// all files without s as a suffix character
})