lstat-dir
Run fs.lstat()
for all contents in a given directory
const lstatDir = ; async { await ; /*=> Map { '/Users/example/node_modules/lstat-dir/LICENSE' => {mode: 33188, size: 1086, ...}, '/Users/example/node_modules/lstat-dir/README.md' => {mode: 33188, size: 2060, ...} '/Users/example/node_modules/lstat-dir/index.js' => {mode: 33188, size: 124, ...} '/Users/example/node_modules/lstat-dir/package.json' => {mode: 33188, size: 922, ...} } */};
Installation
npm install lstat-dir
API
const lstatDir = ;
lstatDir(dir, [options])
dir: string
(directory path)
options: Object
(readdir-sorted
options)
Return: Promise<Map>
The returned Promise
is fulfilled with a Map
, whose keys are absolute paths of contents in the directory, and whose values are fs.Stats
of contents.
/* my-dir ├── file.txt ├── symlink => file.txt └── tmp └── debug.log*/ async { const stats = await ; stats instanceof Map; //=> true stats; /*=> MapIterator { '/Users/example/my-dir/file.txt', '/Users/example/my-dir/symlink', '/Users/example/my-dir/tmp' } */ stats; //=> true stats; //=> true stats; //=> true};
Options are directly passed to the underlying readdir-sorted
to control the order of keys
.
async ...await ; // => ['/path/dir/10.txt', '/path/dir/2.txt', '/path/dir/ä.txt', '/path/dir/z.txt'] ...await ; //=> ['/path/dir/2.txt', '/path/dir/10.txt', '/path/dir/z.txt', '/path/dir/ä.txt'];
License
ISC License © 2017 - 2018 Shinnosuke Watanabe