Security News
New Proposed CISA Mandate Would Require Critical Infrastructure to Report Ransom Payments Within 24 Hours
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
minimatch
Advanced tools
a glob matcher in javascript
Weekly downloads
Package description
The minimatch npm package is a minimal matching utility that implements the string pattern matching functionality, commonly known as 'globbing'. It is used to match text strings with wildcard characters, such as '*' for multiple characters or '?' for a single character. It is often used in file path matching and filtering operations.
Basic string matching
This feature allows for basic pattern matching where a string is tested against a pattern. Wildcards like '*' and '?' can be used to match multiple or single characters respectively.
"use strict";
const minimatch = require("minimatch");
// Match a literal string
console.log(minimatch("foo.js", "foo.js")); // true
// Match with a single wildcard
console.log(minimatch("foo.js", "*.js")); // true
// Match with a single character wildcard
console.log(minimatch("foo.js", "f?o.js")); // true
Negation
This feature allows patterns to be negated so that they match strings that do not match the given pattern.
"use strict";
const minimatch = require("minimatch");
// Negate the match
console.log(minimatch("foo.js", "!foo.js")); // false
console.log(minimatch("bar.js", "!foo.js")); // true
Match options
Minimatch allows for additional options to be set, such as case-insensitivity, to customize the matching behavior.
"use strict";
const minimatch = require("minimatch");
// Match with options
const options = {nocase: true};
console.log(minimatch("FOO.JS", "*.js", options)); // true
Micromatch is a faster and more efficient globbing library with a broader feature set compared to minimatch. It offers advanced pattern matching with support for multiple patterns and extended globbing features.
Glob is a package that provides pattern matching and file system operations. It is more focused on file system globbing rather than string pattern matching, but it uses minimatch under the hood for its matching capabilities.
Multimatch extends minimatch to allow for multiple patterns to be specified at once. It is useful when you need to match against an array of patterns rather than a single pattern.
Anymatch is a package that allows for matching strings against not just patterns, but also against regular expressions and functions. It provides a more flexible matching mechanism compared to minimatch.
FAQs
a glob matcher in javascript
The npm package minimatch receives a total of 132,541,268 weekly downloads. As such, minimatch popularity was classified as popular.
We found that minimatch demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
Security News
Redis is no longer OSS, breaking its explicit commitment to remain under the BSD 3-Clause License forever. This has angered contributors who are now working to fork the software.
Product
Socket AI now enables 'AI detected potential malware' alerts by default, ensuring users benefit from AI-powered state-of-the-art malware detection without needing to opt-in.