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