@cjser/junk 4.0.1-cjser.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cjser/index.cjs +75 -0
- package/index.d.ts +42 -0
- package/index.js +34 -0
- package/license +9 -0
- package/package.json +70 -0
- package/readme.md +43 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// packages/@cjser/junk.tmp-26-1778149222970/index.js
|
|
20
|
+
var index_exports = {};
|
|
21
|
+
__export(index_exports, {
|
|
22
|
+
isJunk: () => isJunk,
|
|
23
|
+
isNotJunk: () => isNotJunk,
|
|
24
|
+
junkRegex: () => junkRegex
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
|
+
var ignoreList = [
|
|
28
|
+
// # All
|
|
29
|
+
"^npm-debug\\.log$",
|
|
30
|
+
// Error log for npm
|
|
31
|
+
"^\\..*\\.swp$",
|
|
32
|
+
// Swap file for vim state
|
|
33
|
+
// # macOS
|
|
34
|
+
"^\\.DS_Store$",
|
|
35
|
+
// Stores custom folder attributes
|
|
36
|
+
"^\\.AppleDouble$",
|
|
37
|
+
// Stores additional file resources
|
|
38
|
+
"^\\.LSOverride$",
|
|
39
|
+
// Contains the absolute path to the app to be used
|
|
40
|
+
"^Icon\\r$",
|
|
41
|
+
// Custom Finder icon: http://superuser.com/questions/298785/icon-file-on-os-x-desktop
|
|
42
|
+
"^\\._.*",
|
|
43
|
+
// Thumbnail
|
|
44
|
+
"^\\.Spotlight-V100(?:$|\\/)",
|
|
45
|
+
// Directory that might appear on external disk
|
|
46
|
+
"\\.Trashes",
|
|
47
|
+
// File that might appear on external disk
|
|
48
|
+
"^__MACOSX$",
|
|
49
|
+
// Resource fork
|
|
50
|
+
// # Linux
|
|
51
|
+
"~$",
|
|
52
|
+
// Backup file
|
|
53
|
+
// # Windows
|
|
54
|
+
"^Thumbs\\.db$",
|
|
55
|
+
// Image file cache
|
|
56
|
+
"^ehthumbs\\.db$",
|
|
57
|
+
// Folder config file
|
|
58
|
+
"^[Dd]esktop\\.ini$",
|
|
59
|
+
// Stores custom folder attributes
|
|
60
|
+
"@eaDir$"
|
|
61
|
+
// Synology Diskstation "hidden" folder where the server stores thumbnails
|
|
62
|
+
];
|
|
63
|
+
var junkRegex = new RegExp(ignoreList.join("|"));
|
|
64
|
+
function isJunk(filename) {
|
|
65
|
+
return junkRegex.test(filename);
|
|
66
|
+
}
|
|
67
|
+
function isNotJunk(filename) {
|
|
68
|
+
return !isJunk(filename);
|
|
69
|
+
}
|
|
70
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
71
|
+
0 && (module.exports = {
|
|
72
|
+
isJunk,
|
|
73
|
+
isNotJunk,
|
|
74
|
+
junkRegex
|
|
75
|
+
});
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Returns `true` if `filename` matches a junk file.
|
|
3
|
+
|
|
4
|
+
@example
|
|
5
|
+
```
|
|
6
|
+
import fs from 'node:fs/promises';
|
|
7
|
+
import {isJunk} from '@cjser/junk';
|
|
8
|
+
|
|
9
|
+
const files = await fs.readdir('some/path');
|
|
10
|
+
|
|
11
|
+
console.log(files);
|
|
12
|
+
//=> ['.DS_Store', 'test.jpg']
|
|
13
|
+
|
|
14
|
+
console.log(files.filter(isJunk));
|
|
15
|
+
//=> ['.DS_Store']
|
|
16
|
+
```
|
|
17
|
+
*/
|
|
18
|
+
export function isJunk(filename: string): boolean;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
Returns `true` if `filename` does not match a junk file.
|
|
22
|
+
|
|
23
|
+
@example
|
|
24
|
+
```
|
|
25
|
+
import fs from 'node:fs/promises';
|
|
26
|
+
import {isNotJunk} from '@cjser/junk';
|
|
27
|
+
|
|
28
|
+
const files = await fs.readdir('some/path');
|
|
29
|
+
|
|
30
|
+
console.log(files);
|
|
31
|
+
//=> ['.DS_Store', 'test.jpg']
|
|
32
|
+
|
|
33
|
+
console.log(files.filter(isNotJunk));
|
|
34
|
+
//=> ['test.jpg']
|
|
35
|
+
```
|
|
36
|
+
*/
|
|
37
|
+
export function isNotJunk(filename: string): boolean;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
Regex used for matching junk files.
|
|
41
|
+
*/
|
|
42
|
+
export const junkRegex: RegExp;
|
package/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const ignoreList = [
|
|
2
|
+
// # All
|
|
3
|
+
'^npm-debug\\.log$', // Error log for npm
|
|
4
|
+
'^\\..*\\.swp$', // Swap file for vim state
|
|
5
|
+
|
|
6
|
+
// # macOS
|
|
7
|
+
'^\\.DS_Store$', // Stores custom folder attributes
|
|
8
|
+
'^\\.AppleDouble$', // Stores additional file resources
|
|
9
|
+
'^\\.LSOverride$', // Contains the absolute path to the app to be used
|
|
10
|
+
'^Icon\\r$', // Custom Finder icon: http://superuser.com/questions/298785/icon-file-on-os-x-desktop
|
|
11
|
+
'^\\._.*', // Thumbnail
|
|
12
|
+
'^\\.Spotlight-V100(?:$|\\/)', // Directory that might appear on external disk
|
|
13
|
+
'\\.Trashes', // File that might appear on external disk
|
|
14
|
+
'^__MACOSX$', // Resource fork
|
|
15
|
+
|
|
16
|
+
// # Linux
|
|
17
|
+
'~$', // Backup file
|
|
18
|
+
|
|
19
|
+
// # Windows
|
|
20
|
+
'^Thumbs\\.db$', // Image file cache
|
|
21
|
+
'^ehthumbs\\.db$', // Folder config file
|
|
22
|
+
'^[Dd]esktop\\.ini$', // Stores custom folder attributes
|
|
23
|
+
'@eaDir$', // Synology Diskstation "hidden" folder where the server stores thumbnails
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
export const junkRegex = new RegExp(ignoreList.join('|'));
|
|
27
|
+
|
|
28
|
+
export function isJunk(filename) {
|
|
29
|
+
return junkRegex.test(filename);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function isNotJunk(filename) {
|
|
33
|
+
return !isJunk(filename);
|
|
34
|
+
}
|
package/license
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cjser/junk",
|
|
3
|
+
"version": "4.0.1-cjser.2",
|
|
4
|
+
"description": "Filter out system junk files like .DS_Store and Thumbs.db",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://code.moenext.com/3rdeye/cjser.git"
|
|
9
|
+
},
|
|
10
|
+
"funding": "https://github.com/sponsors/sindresorhus",
|
|
11
|
+
"author": {
|
|
12
|
+
"name": "Sindre Sorhus",
|
|
13
|
+
"email": "sindresorhus@gmail.com",
|
|
14
|
+
"url": "https://sindresorhus.com"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"exports": {
|
|
18
|
+
"require": "./dist-cjser/index.cjs",
|
|
19
|
+
"default": "./index.js"
|
|
20
|
+
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=12.20"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"test": "xo && ava && tsd"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"index.js",
|
|
29
|
+
"index.d.ts",
|
|
30
|
+
"dist-cjser"
|
|
31
|
+
],
|
|
32
|
+
"keywords": [
|
|
33
|
+
"junk",
|
|
34
|
+
"trash",
|
|
35
|
+
"garbage",
|
|
36
|
+
"files",
|
|
37
|
+
"os",
|
|
38
|
+
"ignore",
|
|
39
|
+
"exclude",
|
|
40
|
+
"filter",
|
|
41
|
+
"temp",
|
|
42
|
+
"tmp",
|
|
43
|
+
"system",
|
|
44
|
+
"clean",
|
|
45
|
+
"cleanup"
|
|
46
|
+
],
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"ava": "^3.15.0",
|
|
49
|
+
"tsd": "^0.17.0",
|
|
50
|
+
"xo": "^0.42.0"
|
|
51
|
+
},
|
|
52
|
+
"main": "./dist-cjser/index.cjs",
|
|
53
|
+
"cjser": {
|
|
54
|
+
"sourceVersion": "4.0.1",
|
|
55
|
+
"cjserVersion": 2,
|
|
56
|
+
"original": {
|
|
57
|
+
"name": "junk",
|
|
58
|
+
"version": "4.0.1",
|
|
59
|
+
"exports": "./index.js",
|
|
60
|
+
"repository": "sindresorhus/junk",
|
|
61
|
+
"files": [
|
|
62
|
+
"index.js",
|
|
63
|
+
"index.d.ts"
|
|
64
|
+
],
|
|
65
|
+
"scripts": {
|
|
66
|
+
"test": "xo && ava && tsd"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# junk
|
|
2
|
+
|
|
3
|
+
> Filter out [system junk files](test.js) like `.DS_Store` and `Thumbs.db`
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
$ npm install junk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
import fs from 'node:fs/promises';
|
|
15
|
+
import {isNotJunk} from 'junk';
|
|
16
|
+
|
|
17
|
+
const files = await fs.readdir('some/path');
|
|
18
|
+
|
|
19
|
+
console.log(files);
|
|
20
|
+
//=> ['.DS_Store', 'test.jpg']
|
|
21
|
+
|
|
22
|
+
console.log(files.filter(isNotJunk));
|
|
23
|
+
//=> ['test.jpg']
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## API
|
|
27
|
+
|
|
28
|
+
### isJunk(filename)
|
|
29
|
+
|
|
30
|
+
Returns `true` if `filename` matches a junk file.
|
|
31
|
+
|
|
32
|
+
### isNotJunk(filename)
|
|
33
|
+
|
|
34
|
+
Returns `true` if `filename` does not match a junk file.
|
|
35
|
+
|
|
36
|
+
### junkRegex
|
|
37
|
+
|
|
38
|
+
Regex used for matching junk files.
|
|
39
|
+
|
|
40
|
+
## cjser
|
|
41
|
+
|
|
42
|
+
This package is a CommonJS-compatible build generated by cjser for projects that still need `require()` support. The source version matches the original npm package version, with a cjser prerelease suffix for this generated build.
|
|
43
|
+
Original repository: https://github.com/sindresorhus/junk
|