Package Exports
- list-directories
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (list-directories) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
list-directories
List all directories in a given directory
const listDirectories = require('list-directories');
/*
./my-dir/a: file
./my-dir/b: directory
./my-dir/c: symlink to a directory
./my-dir/d: directory
*/
(async () => {
await listDirectories('my-dir');
/* => Set {
'/Users/example/my-dir/b',
'/Users/example/my-dir/d'
} */
})();
Installation
npm install list-directories
API
const listDirectories = require('list-directories');
listDirectories(dir)
dir: string
Buffer
URL
(directory path)
options: Object
(readdir-sorted
options)
Return: Promise<Set<string>>
The promise will be fulfilled with a Set
of strings — absolute paths of all directories included in the given directory.
Options are directly passed to the underlying readdir-sorted
to control the order of results.
listDirectories('/dirs').then(files => {
const iterator = files[Symbol.iterator];
iterator.next().value; //=> '/dirs/10'
iterator.next().value; //=> '/dirs/2a'
iterator.next().value; //=> '/dirs/2A'
});
listDirectories('/dirs', {
numeric: true,
caseFirst: 'upper'
}).then(files => {
const iterator = files[Symbol.iterator];
iterator.next().value; //=> '/dirs/2A'
iterator.next().value; //=> '/dirs/2a'
iterator.next().value; //=> '/dirs/10'
});
License
ISC License © 2018 Shinnosuke Watanabe