https://github.com/kuu12/recursive-sync-readdir
Recursive readdirSync using non-recursive loop.
https://github.com/kuu12/recursive-sync-readdir
nodejs readdirsync recursive
Last synced: about 2 months ago
JSON representation
Recursive readdirSync using non-recursive loop.
- Host: GitHub
- URL: https://github.com/kuu12/recursive-sync-readdir
- Owner: kuu12
- License: mit
- Created: 2018-02-02T03:53:05.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-28T05:48:17.000Z (almost 6 years ago)
- Last Synced: 2024-09-01T05:47:29.408Z (9 months ago)
- Topics: nodejs, readdirsync, recursive
- Language: JavaScript
- Size: 6.84 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# recursive-sync-readdir
#### Recursive readdirSync, using `while` loop to prevent call stack from exceeding.[](https://www.npmjs.com/package/recursive-sync-readdir)
[](https://www.npmjs.com/package/recursive-sync-readdir)## Motivation
There are some similiar libraries. But all of them use recursive function calls.
In asynchronous case it's all right, but in synchronous case it may cause ***Maximum call stack size exceeded***.
This library use `while` loop instead of recursive function calls, and **call stack is safe**.## Installation
```shell
npm install recursive-sync-readdir
```## Usage
```javascript
import read from 'recursive-sync-readdir';const files = read(
__dirname, // directory path
[ // exclude rules
/node_modules/, // match regular expression
'.git', // equals to string
path => path === 'dist', // filter function returns true
]
);
```