# readdirrec

> Module for deep directory listing

Latest version **3.0.0** (published 2020-09-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install readdirrec
pnpm add readdirrec
yarn add readdirrec
bun add readdirrec
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2020-09-04 |
| First published | 2018-04-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | tpkn |
| Keywords | read, dir, folder, path, sync, recursive, filter, map, fs, readdir |

## Links

- npm: https://www.npmjs.com/package/readdirrec
- Repository: https://github.com/tpkn/readdirrec
- Homepage: https://github.com/tpkn/readdirrec#readme
- Issues: https://github.com/tpkn/readdirrec/issues
- npm.io page: https://npm.io/package/readdirrec

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 3.0.0 (latest) — 2020-09-04
- 2.3.1 — 2019-02-24
- 2.3.0 — 2019-02-24
- 2.2.0 — 2019-02-24
- 2.1.1 — 2018-05-27
- 2.1.0 — 2018-05-27
- 2.0.4 — 2018-05-13
- 2.0.3 — 2018-04-22
- 2.0.2 — 2018-04-22
- 2.0.1 — 2018-04-22
- 2.0.0 — 2018-04-22

## README

# readdirrec [![npm Package](https://img.shields.io/npm/v/readdirrec.svg)](https://www.npmjs.org/package/readdirrec)
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
```bash
npm install readdirrec
```


## API

```javascript
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
```javascript
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:
* [glob](https://github.com/isaacs/node-glob)
* [globby](https://github.com/sindresorhus/globby)

---
_Source: https://npm.io/package/readdirrec · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
