| Leo Repp | 58b9f11 | 2021-11-22 11:57:47 +0100 | [diff] [blame^] | 1 | declare const junk: { |
| 2 | /** |
| 3 | Returns `true` if `filename` matches a junk file. |
| 4 | */ |
| 5 | is(filename: string): boolean; |
| 6 | |
| 7 | /** |
| 8 | Returns `true` if `filename` doesn't match a junk file. |
| 9 | |
| 10 | @example |
| 11 | ``` |
| 12 | import {promisify} from 'util'; |
| 13 | import * as fs from 'fs'; |
| 14 | import junk = require('junk'); |
| 15 | |
| 16 | const pReaddir = promisify(fs.readdir); |
| 17 | |
| 18 | (async () => { |
| 19 | const files = await pReaddir('some/path'); |
| 20 | |
| 21 | console.log(files); |
| 22 | //=> ['.DS_Store', 'test.jpg'] |
| 23 | |
| 24 | console.log(files.filter(junk.not)); |
| 25 | //=> ['test.jpg'] |
| 26 | })(); |
| 27 | ``` |
| 28 | */ |
| 29 | not(filename: string): boolean; |
| 30 | |
| 31 | /** |
| 32 | Regex used for matching junk files. |
| 33 | */ |
| 34 | readonly regex: RegExp; |
| 35 | |
| 36 | // TODO: Remove this for the next major release |
| 37 | default: typeof junk; |
| 38 | }; |
| 39 | |
| 40 | export = junk; |