simple-recursive-search
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

simple-recursive-search

NPM version build status Test coverage npm download

Async function that retrieves file and directory paths.

This is still an experimental version.

This retrieves the relative path (not just the filenames.), so it's simple to:

  • rename,
  • move
  • or change these files.

Currently it will descend up to the last directory in a tree. A safety limit depth may be added soon.

Installation

$ npm i simple-recursive-search

Usage

import { search: recursiveSearch } from "simple-recursive-search";

recursiveSearch(".",{
  excludeDirs:(dirname) => /node_modules/.test(dirname),
  excludeFiles:(filename) => filename.endsWith(".jpg"),
  wantFiles:true,// default, dont need to pass
  wantDirectories:false//default, dont need to pass
  dotFiles:false//default, dont need to pass
}).then((matches) => {
  console.log(matches);
});

Or using await

import { search: recursiveSearch } from "simple-recursive-search";
async function run(){
const listOfFilesMatched = await recursiveSearch(".",{
  excludeDirs:(dirname) => /node_modules/.test(dirname)
})}
console.log(listOfFilesMatched)

License

MIT

Package Sidebar

Install

npm i simple-recursive-search

Weekly Downloads

13

Version

3.0.0

License

MIT

Unpacked Size

24.5 kB

Total Files

37

Last publish

Collaborators

  • santimir