Skip to content

kuu12/recursive-sync-readdir

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

recursive-sync-readdir

Recursive readdirSync, using while loop to prevent call stack from exceeding.

NpmVersion npm bundle size (minified)

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

npm install recursive-sync-readdir

Usage

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
    ]
);

About

Recursive readdirSync using non-recursive loop.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published