Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shinnn/readdir-clean
Like `fs.readdir`, but excludes autogenerated contents for example .DS_Store and Thumbs.db
https://github.com/shinnn/readdir-clean
filesystem filter javascript list nodejs promise readdir
Last synced: 27 days ago
JSON representation
Like `fs.readdir`, but excludes autogenerated contents for example .DS_Store and Thumbs.db
- Host: GitHub
- URL: https://github.com/shinnn/readdir-clean
- Owner: shinnn
- License: isc
- Created: 2017-06-19T11:58:17.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-04-12T14:15:57.000Z (over 5 years ago)
- Last Synced: 2024-04-15T00:04:39.277Z (7 months ago)
- Topics: filesystem, filter, javascript, list, nodejs, promise, readdir
- Language: JavaScript
- Homepage:
- Size: 82 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# readdir-clean
[![npm version](https://img.shields.io/npm/v/readdir-clean.svg)](https://www.npmjs.com/package/readdir-clean)
[![Build Status](https://travis-ci.com/shinnn/readdir-clean.svg?branch=master)](https://travis-ci.com/shinnn/readdir-clean)
[![Coverage Status](https://img.shields.io/coveralls/shinnn/readdir-clean.svg)](https://coveralls.io/github/shinnn/readdir-clean?branch=master)Like [`fs.promises.readdir()`](https://nodejs.org/api/fs.html#fs_fspromises_readdir_path_options) but excludes autogenerated contents for example `.DS_Store` and `Thumbs.db`
```javascript
const {readdir} = require('fs').promises;
const readdirClean = require('readdir-clean');(async () => {
await readdir('.');
/*=> [
'.DS_Store',
'.AppleDouble',
'.LSOverride',
'a.txt',
'b.txt',
'Thumbs.db'
] */await readdirClean('.');
/*=> [
'a.txt',
'b.txt'
] */
})();
```## Installation
[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/about-npm/).
```
npm install readdir-clean
```## API
```javascript
const readdirClean = require('readdir-clean');
```### readdirClean(*path*)
*path*: `string | Buffer | Uint8Array | URL` (directory path)
Return: `Promise`Similar to [Node.js](https://nodejs.org) built-in `fs.promises.readdir()`, but different in the following points:
* `encoding` option is not supported.
* The paths are filtered with [`require('junk').not`](https://github.com/sindresorhus/junk#junknotfilename).```javascript
(async () => {
const paths = await readdirClean('path/to/dir');paths.includes('.Spotlight-V100'); //=> false
paths.includes('.Trashes'); //=> false
paths.includes('Desktop.ini'); //=> false
})();
```## License
[ISC License](./LICENSE) © 2017 - 2019 Shinnosuke Watanabe