@open-tech-world/es-glob

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')
matchGlob('a/b/.x/c/d', '**/.x/**')
matchGlob('abc', 'ab?')
matchGlob('b', '[a-c]')
matchGlob('a', '[!a-c]')
matchGlob('b', '[^a-c]')
matchGlob('*.txt', '\\*.txt')
matchGlob('node_modules', '!node_modules')
matchGlob('a', '(a|b)')
matchGlob('config.js', '*.(js|json)')
matchGlob('tsconfig.json', '*.(js|json)')
matchGlob('index.ts', '*.(js|jsx|tsx)')
matchPathGlob
It matches a path in a glob pattern.
import { matchPathGlob } from '@open-tech-world/es-glob';
matchPathGlob('a', 'a/*')
matchPathGlob('a/b', 'a/*')
matchPathGlob('a/b/c', 'a/*')
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).