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

    junk

Filter out OS junk files like .DS_Store and Thumbs.db


Version published
Maintainers
1
Install size
4.38 kB
Created

Package description

What is junk?

The 'junk' npm package is a small utility that helps in filtering out system files and other non-essential files from an array of filenames. It is particularly useful when dealing with file listings that may include unwanted files like '.DS_Store' on macOS or 'Thumbs.db' on Windows.

What are junk's main functionalities?

Filter out junk files from a list

This feature allows you to remove common system-generated files from an array of filenames, ensuring that only relevant files are processed or displayed.

const junk = require('junk');

const files = ['file1.txt', '.DS_Store', 'file2.txt', 'Thumbs.db'];
const cleanFiles = files.filter(junk.not);
console.log(cleanFiles); // Output: ['file1.txt', 'file2.txt']

Identify if a file is considered junk

This function checks if a single filename is considered 'junk' by comparing it against a predefined list of junk file names.

const junk = require('junk');

console.log(junk.is('.DS_Store')); // Output: true
console.log(junk.is('file1.txt')); // Output: false

Other packages similar to junk

Readme

Source

junk Build Status

Filter out OS junk files like .DS_Store and Thumbs.db

Install

$ npm install --save junk

Usage

var fs = require('fs');
var junk = require('junk');

fs.readdir('path', function (err, files) {
	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.re

The regex used for matching.

License

MIT © Sindre Sorhus

Keywords

FAQs

Last updated on 22 Feb 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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