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.
glob
Advanced tools
the most correct and second fastest glob implementation in JavaScript
Weekly downloads
Package description
The glob npm package allows users to match file paths against specified patterns similar to how shell works. It is widely used for tasks such as file searching, filtering, and bulk operations on sets of files.
File Pattern Matching
Match files using the patterns the shell uses, like stars and stuff.
const glob = require('glob');
glob('**/*.js', function (er, files) {
// files is an array of filenames.
// If the `nonull` option is set, and nothing
// was found, then files is ["**/*.js"]
// er is an error object or null.
console.log(files);
});
Synchronous File Pattern Matching
Perform a synchronous glob search.
const glob = require('glob');
const files = glob.sync('**/*.js');
// files is an array of filenames found matching the pattern.
console.log(files);
Pattern Matching with Promises
Use glob with Promises for better async control flow.
const glob = require('glob');
const util = require('util');
const globPromise = util.promisify(glob);
globPromise('**/*.js').then(files => {
console.log(files);
}).catch(err => {
console.error('Error occurred:', err);
});
Minimatch is a minimal matching utility that works similarly to glob but focuses on the pattern matching algorithm itself. It is actually used by glob under the hood for its matching capabilities.
Fast-glob is an alternative to glob that claims to be faster due to its use of streams and parallel processing. It provides a similar API and is often used when performance is a critical factor.
Globule is another pattern matching library that extends the functionality of glob with additional features like filtering matched files using other patterns. It provides a more granular control over the file matching process.
Micromatch is a smaller, more efficient, and highly configurable globbing library. It provides a powerful and expressive API for pattern matching and is designed to be faster and safer than minimatch.
FAQs
the most correct and second fastest glob implementation in JavaScript
The npm package glob receives a total of 112,124,737 weekly downloads. As such, glob popularity was classified as popular.
We found that glob 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.