list-empty-files
v1.0.0
Published
List all empty files in a given directory
Downloads
5
Maintainers
Readme
list-empty-files
List all empty files in a given directory
const listEmptyFiles = require('list-empty-files');
/*
a.txt: 'Hi'
b.txt: ''
c.txt: 'Hello'
d.txt: ''
*/
listEmptyFiles('my-dir').then(files => {
files;
/* Set {
'/Users/example/my-dir/b.txt',
'/Users/example/my-dir/d.txt'
} */
});
Installation
npm install list-empty-files
API
const listEmptyFiles = require('list-empty-files');
listEmptyFiles(dir)
dir: string
(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 zero byte files included in the given directory.
Options are directly passed to the underlying readdir-sorted
to control the order of results.
listEmptyFiles('/empty-files').then(files => {
const iterator = files.keys();
iterator.next().value; //=> '/empty-files/10.js'
iterator.next().value; //=> '/empty-files/2a.js'
iterator.next().value; //=> '/empty-files/2A.js'
});
listEmptyFiles('/dir', {
numeric: true,
caseFirst: 'upper'
}).then(files => {
const iterator = files.keys();
iterator.next().value; //=> '/empty-files/2A.js'
iterator.next().value; //=> '/empty-files/2a.js'
iterator.next().value; //=> '/empty-files/10.js'
});
License
ISC License © 2018 Shinnosuke Watanabe