Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including junk with all npm packages installed. Try it out:

var junk = require("junk")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

junk v3.1.0

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

junk Build Status

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

Install

$ npm install junk

Usage

const {promisify} = require('util');
const fs = require('fs');
const junk = require('junk');

const pReaddir = promisify(fs.readdir);

(async () => {
    const files = await pReaddir('some/path');

    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.regex

Regex used for matching junk files.

License

MIT © Sindre Sorhus

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free