3.0.0 • Published 4 years ago

readdirrec v3.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

readdirrec npm Package

Module for deep directory listing

  • Choose if it should be just files, or folders, or both
  • Turn off recursion if needed
  • Return results with relative path
  • Use it both synchronous or asynchronous version

Installation

npm install readdirrec

API

await rdr(path[, options])

path

Type: String

options.files_only

Type: Boolean
Default: true
Find files only

options.folders_only

Type: Boolean
Default: false
Find folders only

options.recursive

Type: Boolean
Default: true
If false then path would be the only level for search

options.relative

Type: Boolean
Default: false
Cut the path from the results

options.filter

Type: Function | Object

Usage

const rdr = require('readdirrec');

// Cut root_dir part from path of each file/folder
await rdr(folder, { relative: true })

// Get folders only
await rdr(folder, { folders_only: true })

// Get both files ond folder
await rdr(folder, { files_only: false, folders_only: false })


// Different filters
await rdr(folder, { filter: file => /config\.js/.test(file) })
// => ['config.js']

await rdr(folder, { filter: { ext: '.js' } })
// => ['file1.js', 'file2.js']

await rdr(folder, { filter: { ext: ['.js', '.zip'] } })
// => ['file1.js', 'file2.js', 'archive.zip']

Changelog

v3.0.0 (2020-09-04):

  • removed synchronous version
  • removed try/catch wrapper, so now module throws all exceptions as it should be
  • fixed a bunch of different bugs

Related

More advanced modules:

3.0.0

4 years ago

2.3.1

5 years ago

2.3.0

5 years ago

2.2.0

5 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago