Socket
Book a DemoInstallSign in
Socket

@open-tech-world/es-glob

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@open-tech-world/es-glob

A glob pattern matching library.

latest
Source
npmnpm
Version
0.8.1
Version published
Maintainers
1
Created
Source

@open-tech-world/es-glob

Build CodeFactor

A glob pattern matching library.

Supported glob patterns

Basic

✔️ * (Wildcard)

✔️ ** (Globstar)

✔️ ? (Wildcard)

✔️ […] (Brackets)

✔️ \\ (Escape Special Characters)

✔️ ! (Negation)

Braces

🚧 {,} (Brace Matching)

Extended glob

?(pattern-list)

*(pattern-list)

+(pattern-list)

@(pattern-list)

!(pattern-list)

POSIX Character classes

[:class:]

Others

❌ Regular expression

✔️ (|) Logical OR Group

Installation

Using npm

npm install @open-tech-world/es-glob

Using Yarn

yarn add @open-tech-world/es-glob

Usage

import { matchGlob } from '@open-tech-world/es-glob';

matchGlob(str: string, pattern: string): boolean;

Examples

matchGlob('/a.json', '/*.json') // true

matchGlob('a/b/.x/c/d', '**/.x/**') // true

matchGlob('abc', 'ab?') // true

matchGlob('b', '[a-c]') // true

matchGlob('a', '[!a-c]') // false

matchGlob('b', '[^a-c]') // false

matchGlob('*.txt', '\\*.txt') // true

matchGlob('node_modules', '!node_modules') // false

matchGlob('a', '(a|b)') // true

matchGlob('config.js', '*.(js|json)') // true

matchGlob('tsconfig.json', '*.(js|json)') // true

matchGlob('index.ts', '*.(js|jsx|tsx)') // false

matchPathGlob

It matches a path in a glob pattern.

import { matchPathGlob } from '@open-tech-world/es-glob';

matchPathGlob('a', 'a/*') // true
matchPathGlob('a/b', 'a/*') // true
matchPathGlob('a/b/c', 'a/*') // false

References

https://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.html

https://en.wikipedia.org/wiki/Glob_(programming)

License

Copyright (c) 2021, Thanga Ganapathy (MIT License).

Keywords

glob

FAQs

Package last updated on 11 Aug 2021

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