1.0.0 • Published 6 years ago

list-empty-files v1.0.0

Weekly downloads
3
License
ISC
Repository
github
Last release
6 years ago

list-empty-files

npm version Build Status Coverage Status

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

Use npm.

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

1.0.0

6 years ago

0.5.0

7 years ago

0.4.0

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago

0.0.0

7 years ago