Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
wildcard-match
Advanced tools
The wildcard-match npm package is used for matching strings against wildcard patterns. It is useful for tasks such as filtering file paths, validating input strings, and more.
Basic Wildcard Matching
This feature allows you to check if a string matches a given wildcard pattern. In this example, 'foobar' matches the pattern 'foo*'.
const wildcard = require('wildcard-match');
const isMatch = wildcard('foo*')('foobar');
console.log(isMatch); // true
Case-Insensitive Matching
This feature allows for case-insensitive matching. In this example, 'FOOBAR' matches the pattern 'foo*' when case sensitivity is turned off.
const wildcard = require('wildcard-match');
const isMatch = wildcard('foo*', { caseSensitive: false })('FOOBAR');
console.log(isMatch); // true
Custom Wildcard Characters
This feature allows you to define custom wildcard characters. In this example, '#' is used as the wildcard character instead of the default '*'.
const wildcard = require('wildcard-match');
const isMatch = wildcard('foo#', { wildcard: '#' })('foo123');
console.log(isMatch); // true
Minimatch is a powerful glob matching library that supports a wide range of glob patterns. It is more feature-rich compared to wildcard-match, offering advanced pattern matching capabilities.
Micromatch is a fast and lightweight glob matcher that supports extended glob patterns and advanced matching features. It is known for its performance and flexibility, making it a good alternative to wildcard-match.
Multimatch is a library that allows you to match multiple glob patterns against a list of strings. It is built on top of minimatch and provides additional functionality for handling multiple patterns efficiently.
A function that matches two glob-like patterns with each other. It has an advantage over other similar libraries in that it allows both samples to have wildcards.
npm install --save wildcard-match
let match = require('wildcard-match');
console.log(match('one/**', 'one/two/three')); // true
console.log(match('.', ['one', '**', 'four'], 'one.two.three.four')); // true
console.log(match('one.two', 'one.two.*')); // false because * matches exactly one segment
Patterns can be either strings or arrays, and can have the following wildcards:
*
for exactly one segment**
for any number of segments (including zero)If at least one of the samples is a string, a delimiter can be provided as the first argument. If the delimiter is not specified, /
is used.
FAQs
A tiny and extremely fast library for compiling and matching basic glob patterns
The npm package wildcard-match receives a total of 373,813 weekly downloads. As such, wildcard-match popularity was classified as popular.
We found that wildcard-match demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.