Skip to content

Node.js module to read the contents of a directory with filters. Provides wrappers to fs.readdir to return just files or directories.

License

Notifications You must be signed in to change notification settings

justinkalland/d-list

Repository files navigation

d-list

Node.js module to read the contents of a directory with filters. Provides wrappers to fs.readdir to return just files or directories.

Installation

npm install d-list

Usage

Async examples

example/
├── some_items/
├── another_dir/
├── foo.txt
└── bar.txt
import dl from 'd-list'
const path = 'example'

dl.getDirs(path).then(dirList => {
    console.log(dirList)
    // ['some_items', 'another_dir']
})

dl.getFiles(path).then(fileList => {
    console.log(fileList)
    // ['foo.txt', 'bar.txt']
})

Sync examples

example/
├── some_items/
├── another_dir/
├── foo.txt
└── bar.txt
import dl from 'd-list'
const path = 'example'

const dirList = dl.getDirsSync(path)
console.log(dirList)
// ['some_items', 'another_dir']

const fileList = dl.getFilesSync(path)
console.log(fileList)
// ['foo.txt', 'bar.txt']

About

Node.js module to read the contents of a directory with filters. Provides wrappers to fs.readdir to return just files or directories.

Topics

Resources

License

Stars

Watchers

Forks