blob: 74c23ca3659d83a2b7b27666a9903c38650eabd3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# junk [![Build Status](https://travis-ci.org/sindresorhus/junk.svg?branch=master)](https://travis-ci.org/sindresorhus/junk)
> Filter out [system junk files](test.js) like `.DS_Store` and `Thumbs.db`
## Install
```
$ npm install junk
```
## Usage
```js
const {promisify} = require('util');
const fs = require('fs');
const junk = require('junk');
const pReaddir = promisify(fs.readdir);
(async () => {
const files = await pReaddir('some/path');
console.log(files);
//=> ['.DS_Store', 'test.jpg']
console.log(files.filter(junk.not));
//=> ['test.jpg']
})();
```
## API
### junk.is(filename)
Returns `true` if `filename` matches a junk file.
### junk.not(filename)
Returns `true` if `filename` doesn't match a junk file.
### junk.regex
Regex used for matching junk files.
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)
|