Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

glob-promise

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

glob-promise

Promise version of glob

  • 1.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.1M
increased by2.06%
Maintainers
1
Weekly downloads
 
Created

What is glob-promise?

The glob-promise package is a wrapper for the 'glob' library that provides a way to use glob functionality with promises instead of callbacks. This allows for better integration with modern JavaScript's async/await syntax and improves the readability and maintainability of asynchronous file pattern matching code.

What are glob-promise's main functionalities?

Asynchronous file pattern matching

Use glob patterns to asynchronously find files and directories in your project that match the given pattern. The function returns a promise that resolves with an array of matching paths.

const glob = require('glob-promise');

async function findFiles(pattern) {
  try {
    const files = await glob(pattern);
    console.log(files);
  } catch (error) {
    console.error('Error matching files:', error);
  }
}

findFiles('**/*.js');

Synchronous file pattern matching

Provides a synchronous method to perform file pattern matching, which can be useful in scenarios where asynchronous operations are not possible or desired.

const glob = require('glob-promise');

function findFilesSync(pattern) {
  try {
    const files = glob.sync(pattern);
    console.log(files);
  } catch (error) {
    console.error('Error matching files:', error);
  }
}

findFilesSync('**/*.js');

Options customization

Allows customization of the file matching process by passing an options object. This can include ignoring certain patterns, specifying the root directory, and more.

const glob = require('glob-promise');

async function findFilesWithIgnores(pattern, ignores) {
  const options = { ignore: ignores };
  try {
    const files = await glob(pattern, options);
    console.log(files);
  } catch (error) {
    console.error('Error matching files:', error);
  }
}

findFilesWithIgnores('**/*.js', ['node_modules/**']);

Other packages similar to glob-promise

Keywords

FAQs

Package last updated on 14 Sep 2015

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc