Socket
Socket
Sign inDemoInstall

junk

Package Overview
Dependencies
0
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.1.0 to 4.0.0

64

index.d.ts

@@ -1,40 +0,42 @@

declare const junk: {
/**
Returns `true` if `filename` matches a junk file.
*/
is(filename: string): boolean;
/**
Returns `true` if `filename` matches a junk file.
/**
Returns `true` if `filename` doesn't match a junk file.
@example
```
import fs from 'node:fs/promises';
import {isJunk} from 'junk';
@example
```
import {promisify} from 'util';
import * as fs from 'fs';
import junk = require('junk');
const files = await fs.readdir('some/path');
const pReaddir = promisify(fs.readdir);
console.log(files);
//=> ['.DS_Store', 'test.jpg']
(async () => {
const files = await pReaddir('some/path');
console.log(files.filter(isJunk));
//=> ['.DS_Store']
```
*/
export function isJunk(filename: string): boolean;
console.log(files);
//=> ['.DS_Store', 'test.jpg']
/**
Returns `true` if `filename` does not match a junk file.
console.log(files.filter(junk.not));
//=> ['test.jpg']
})();
```
*/
not(filename: string): boolean;
@example
```
import fs from 'node:fs/promises';
import {isNotJunk} from 'junk';
/**
Regex used for matching junk files.
*/
readonly regex: RegExp;
const files = await fs.readdir('some/path');
// TODO: Remove this for the next major release
default: typeof junk;
};
console.log(files);
//=> ['.DS_Store', 'test.jpg']
export = junk;
console.log(files.filter(isNotJunk));
//=> ['test.jpg']
```
*/
export function isNotJunk(filename: string): boolean;
/**
Regex used for matching junk files.
*/
export const junkRegex: RegExp;

@@ -1,4 +0,2 @@

'use strict';
const blacklist = [
const ignoreList = [
// # All

@@ -25,16 +23,13 @@ '^npm-debug\\.log$', // Error log for npm

'^Desktop\\.ini$', // Stores custom folder attributes
'@eaDir$' // Synology Diskstation "hidden" folder where the server stores thumbnails
'@eaDir$', // Synology Diskstation "hidden" folder where the server stores thumbnails
];
exports.re = () => {
throw new Error('`junk.re` was renamed to `junk.regex`');
};
export const junkRegex = new RegExp(ignoreList.join('|'));
exports.regex = new RegExp(blacklist.join('|'));
export function isJunk(filename) {
return junkRegex.test(filename);
}
exports.is = filename => exports.regex.test(filename);
exports.not = filename => !exports.is(filename);
// TODO: Remove this for the next major release
exports.default = module.exports;
export function isNotJunk(filename) {
return !isJunk(filename);
}
{
"name": "junk",
"version": "3.1.0",
"version": "4.0.0",
"description": "Filter out system junk files like .DS_Store and Thumbs.db",
"license": "MIT",
"repository": "sindresorhus/junk",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=8"
"node": ">=12.20"
},

@@ -38,6 +41,6 @@ "scripts": {

"devDependencies": {
"ava": "^1.4.1",
"tsd": "^0.7.1",
"xo": "^0.24.0"
"ava": "^3.15.0",
"tsd": "^0.17.0",
"xo": "^0.42.0"
}
}

@@ -1,6 +0,5 @@

# junk [![Build Status](https://travis-ci.org/sindresorhus/junk.svg?branch=master)](https://travis-ci.org/sindresorhus/junk)
# junk
> Filter out [system junk files](test.js) like `.DS_Store` and `Thumbs.db`
## Install

@@ -12,41 +11,29 @@

## Usage
```js
const {promisify} = require('util');
const fs = require('fs');
const junk = require('junk');
import fs from 'node:fs/promises';
import {isNotJunk} from 'junk';
const pReaddir = promisify(fs.readdir);
const files = await fs.readdir('some/path');
(async () => {
const files = await pReaddir('some/path');
console.log(files);
//=> ['.DS_Store', 'test.jpg']
console.log(files);
//=> ['.DS_Store', 'test.jpg']
console.log(files.filter(junk.not));
//=> ['test.jpg']
})();
console.log(files.filter(isNotJunk));
//=> ['test.jpg']
```
## API
### junk.is(filename)
### isJunk(filename)
Returns `true` if `filename` matches a junk file.
### junk.not(filename)
### isNotJunk(filename)
Returns `true` if `filename` doesn't match a junk file.
Returns `true` if `filename` does not match a junk file.
### junk.regex
### junkRegex
Regex used for matching junk files.
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc