Socket
Socket
Sign inDemoInstall

multimatch

Package Overview
Dependencies
6
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    multimatch

Extends minimatch.match() with support for multiple patterns


Version published
Weekly downloads
3.8M
decreased by-20.57%
Maintainers
1
Created
Weekly downloads
 

Package description

What is multimatch?

The multimatch npm package allows for matching file paths against specified glob patterns. It is a wrapper around the 'minimatch' library, providing the ability to use multiple patterns at once for more complex matching scenarios. This can be particularly useful in build processes, file selection for operations like copying, deleting, or applying specific processing, and in any context where a list of files needs to be filtered based on flexible criteria.

What are multimatch's main functionalities?

Basic glob matching

This feature demonstrates basic usage of multimatch to filter an array of file paths based on a simple glob pattern. It's useful for selecting files of a specific type.

const multimatch = require('multimatch');
const paths = ['index.html', 'styles/main.css', 'scripts/app.js'];
const matched = multimatch(paths, '*.html');
console.log(matched); // ['index.html']

Multiple pattern matching

This feature shows how to use multimatch with multiple patterns to filter file paths. It's particularly useful when you need to select files that match any of several criteria.

const multimatch = require('multimatch');
const paths = ['index.html', 'styles/main.css', 'scripts/app.js', 'images/logo.png'];
const matched = multimatch(paths, ['*.css', '*.js']);
console.log(matched); // ['styles/main.css', 'scripts/app.js']

Exclusion patterns

This feature illustrates the use of exclusion patterns to filter out files that match a certain pattern. It's useful for excluding specific files or directories from a broader selection.

const multimatch = require('multimatch');
const paths = ['index.html', 'styles/main.css', 'scripts/app.js', 'test/app.test.js'];
const matched = multimatch(paths, ['*.js', '!test/*.js']);
console.log(matched); // ['scripts/app.js']

Other packages similar to multimatch

Readme

Source

multimatch Build Status

Extends minimatch.match() with support for multiple patterns

Comparison

Minimatch:

minimatch.match(['unicorn', 'cake', 'rainbows'], '*corn');

Multimatch:

multimatch(['unicorn', 'cake', 'rainbows'], ['*corn', 'rain*']);

Install


$ npm install --save multimatch

Usage

var multimatch = require('multimatch');

multimatch(['unicorn', 'cake', 'rainbows'], ['*', '!cake']);
//=> ['unicorn', 'rainbows']

See the tests for more usage examples and expected matches.

API

Same as minimatch.match() except for pattern also accepting an array.

License

MIT © Sindre Sorhus, Jon Schlinkert

Keywords

FAQs

Last updated on 21 Jun 2014

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