Socket
Socket
Sign inDemoInstall

glob

Package Overview
Dependencies
0
Maintainers
1
Versions
144
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

glob

the most correct and second fastest glob implementation in JavaScript


Version published
Maintainers
1
Weekly downloads
136,156,302
decreased by-8.89%

Weekly downloads

Package description

What is glob?

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.

What are glob's main functionalities?

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);
});

Other packages similar to glob

FAQs

Last updated on 28 Mar 2024

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