Socket
Socket
Sign inDemoInstall

is-glob

Package Overview
Dependencies
1
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    is-glob

Returns `true` if the given string looks like a glob pattern or an extglob pattern. This makes it easy to create code that only uses external modules like node-glob when necessary, resulting in much faster code execution and initialization time, and a bet


Version published
Weekly downloads
59M
decreased by-1.05%
Maintainers
2
Install size
16.0 kB
Created
Weekly downloads
 

Package description

What is is-glob?

The is-glob npm package is used to determine if a string is a glob pattern. A glob pattern is a string that defines a pattern for matching file names, typically used for file searching and manipulation. The package provides a simple API to check if a string contains characters that make it a valid glob pattern.

What are is-glob's main functionalities?

Check if a string is a glob pattern

This feature allows you to check if a given string is a glob pattern. It returns true if the string contains special characters like '*', '?', or '[...]' that are used in glob patterns, and false otherwise.

const isGlob = require('is-glob');

console.log(isGlob('*.js')); // true
console.log(isGlob('hello.txt')); // false

Check if an array contains a glob pattern

This feature checks if any element in an array is a glob pattern. It returns true if at least one element is a glob pattern, and false if none are.

const isGlob = require('is-glob');

console.log(isGlob(['css', '*.js'])); // true
console.log(isGlob(['css', 'js'])); // false

Other packages similar to is-glob

Readme

Source

is-glob NPM version NPM downloads Build Status

Returns true if the given string looks like a glob pattern or an extglob pattern. This makes it easy to create code that only uses external modules like node-glob when necessary, resulting in much faster code execution and initialization time, and a better user experience.

Install

Install with npm:

$ npm install --save is-glob

You might also be interested in is-valid-glob and has-glob.

Usage

var isGlob = require('is-glob');

True

Patterns that have glob characters or regex patterns will return true:

isGlob('!foo.js');
isGlob('*.js');
isGlob('**/abc.js');
isGlob('abc/*.js');
isGlob('abc/(aaa|bbb).js');
isGlob('abc/[a-z].js');
isGlob('abc/{a,b}.js');
isGlob('abc/?.js');
//=> true

Extglobs

isGlob('abc/@(a).js');
isGlob('abc/!(a).js');
isGlob('abc/+(a).js');
isGlob('abc/*(a).js');
isGlob('abc/?(a).js');
//=> true

False

Escaped globs or extglobs return false:

isGlob('abc/\\@(a).js');
isGlob('abc/\\!(a).js');
isGlob('abc/\\+(a).js');
isGlob('abc/\\*(a).js');
isGlob('abc/\\?(a).js');
isGlob('\\!foo.js');
isGlob('\\*.js');
isGlob('\\*\\*/abc.js');
isGlob('abc/\\*.js');
isGlob('abc/\\(aaa|bbb).js');
isGlob('abc/\\[a-z].js');
isGlob('abc/\\{a,b}.js');
isGlob('abc/\\?.js');
//=> false

Patterns that do not have glob patterns return false:

isGlob('abc.js');
isGlob('abc/def/ghi.js');
isGlob('foo.js');
isGlob('abc/@.js');
isGlob('abc/+.js');
isGlob();
isGlob(null);
//=> false

Arrays are also false (If you want to check if an array has a glob pattern, use has-glob):

isGlob(['**/*.js']);
isGlob(['foo.js']);
//=> false

About

  • assemble: Get the rocks out of your socks! Assemble makes you fast at creating web projects… more | homepage
  • base: base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting… more | homepage
  • update: Be scalable! Update is a new, open source developer framework and CLI for automating updates… more | homepage
  • verb: Documentation generator for GitHub projects. Verb is extremely powerful, easy to use, and is used… more | homepage

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Building docs

(This document was generated by verb-generate-readme (a verb generator), please don't edit the readme directly. Any changes to the readme must be made in .verb.md.)

To generate the readme and API documentation with verb:

$ npm install -g verb verb-generate-readme && verb

Running tests

Install dev dependencies:

$ npm install -d && npm test

Author

Jon Schlinkert

License

Copyright © 2016, Jon Schlinkert. Released under the MIT license.


This file was generated by verb-generate-readme, v0.1.30, on September 03, 2016.

Keywords

FAQs

Last updated on 03 Sep 2016

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