1.0.1 • Published 4 years ago

d-list v1.0.1

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

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']