Socket
Socket
Sign inDemoInstall

micromatch

Package Overview
Dependencies
8
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    micromatch

Glob matching for javascript/node.js. Like minimatch, but 10-40x faster.


Version published
Weekly downloads
59M
increased by2.89%
Maintainers
1
Install size
93.3 kB
Created
Weekly downloads
 

Package description

What is micromatch?

The micromatch npm package is a fast, minimal glob utility for node.js and JavaScript. It is used to parse, match, and expand glob patterns against strings to filter, validate, or manipulate file paths, names, and other string lists.

What are micromatch's main functionalities?

Matching glob patterns

Match an array of strings to a glob pattern. In this example, it filters the list to include only files ending with '.js'.

const micromatch = require('micromatch');
const result = micromatch(['foo.js', 'bar.js'], '*.js');
console.log(result); // ['foo.js', 'bar.js']

Negating glob patterns

Use negation patterns to exclude matches. This example matches all '.js' files but excludes 'foo.js'.

const micromatch = require('micromatch');
const result = micromatch(['foo.js', 'bar.js', 'baz.txt'], ['*.js', '!foo.js']);
console.log(result); // ['bar.js']

Testing a filepath

Test a single filepath against a glob pattern to see if it matches. In this case, 'foobar.js' is a match for '*.js'.

const micromatch = require('micromatch');
const isMatch = micromatch.isMatch('foobar.js', '*.js');
console.log(isMatch); // true

Expanding braces

Expand braces in glob patterns to match multiple patterns. This example matches 'foo.js' and 'foo1.js' with a single pattern.

const micromatch = require('micromatch');
const result = micromatch(['foo.js', 'foo1.js'], 'foo{,1}.js');
console.log(result); // ['foo.js', 'foo1.js']

Other packages similar to micromatch

Readme

Source

micromatch NPM version

Glob matching for javascript/node.js. Like minimatch, but 10-40x faster.

  • 5-40x faster than minimatch (benchmarks)
  • Extensice unit tests, well-organized code-base

Features

Supports

All the mainstream glob features you're used to using in your gulp and Grunt tasks:

  • Brace Expansion - ex. foo/bar-{1..5}.md, one/{two,three}/four.md
  • Globstar matching - ex. **/*, a/b/*.js

Does not support

  • Extended glob matching. This might be supported in the future, either in core or as an extension, but it's hard to justify the cost in terms of speed and complexity for features no that are rarely used.

Install with npm

npm i micromatch --save

Usage

var micromatch = require('micromatch');

mm(['a.js', 'b.md', 'c.txt'], '*.{js,txt}');
//=> ['a.js', 'c.txt']

Also supports negation patterns:

mm(['a.js', 'b.md', 'c.txt'], '!*.{js,txt}');
//=> ['b.md']

mm(['a.md', 'b.js', 'c.txt', 'd.json'], ['*.*', '!*.{js,txt}']);
//=> ['a.md', 'd.json']

Benchmarks

Run the benchmarks

node benchmark/

image

Run tests

Install dev dependencies

npm i -d && mocha

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Jon Schlinkert

License

Copyright (c) 2014 Jon Schlinkert
Released under the MIT license


This file was generated by verb on December 23, 2014.

Keywords

FAQs

Last updated on 23 Dec 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