Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shinnn/list-empty-files
List all empty files in a given directory
https://github.com/shinnn/list-empty-files
Last synced: 27 days ago
JSON representation
List all empty files in a given directory
- Host: GitHub
- URL: https://github.com/shinnn/list-empty-files
- Owner: shinnn
- License: isc
- Created: 2017-04-13T10:44:00.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-02T00:58:20.000Z (almost 7 years ago)
- Last Synced: 2024-10-13T14:13:36.325Z (about 1 month ago)
- Language: JavaScript
- Size: 25.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# list-empty-files
[![npm version](https://img.shields.io/npm/v/list-empty-files.svg)](https://www.npmjs.com/package/list-empty-files)
[![Build Status](https://travis-ci.org/shinnn/list-empty-files.svg?branch=master)](https://travis-ci.org/shinnn/list-empty-files)
[![Coverage Status](https://img.shields.io/coveralls/shinnn/list-empty-files.svg)](https://coveralls.io/github/shinnn/list-empty-files?branch=master)List all empty files in a given directory
```javascript
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
[Use npm.](https://docs.npmjs.com/cli/install)
```
npm install list-empty-files
```## API
```javascript
const listEmptyFiles = require('list-empty-files');
```### listEmptyFiles(*dir*)
*dir*: `string` (directory path)
*options*: `Object` ([`readdir-sorted`](https://github.com/shinnn/readdir-sorted) options)
Return: `Promise>`The promise will be fulfilled with a [`Set`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set) of strings — absolute paths of all zero byte files included in the given directory.
Options are directly passed to the underlying [`readdir-sorted`](https://github.com/shinnn/readdir-sorted#readdirsortedpath--options) to control the order of results.
```javascript
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](./LICENSE) © 2018 Shinnosuke Watanabe