Skip to content

bit-js/globc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Globc

An insanely fast cross-runtime glob pattern matcher.

import { createMatcher } from "@bit-js/globc";

const match = createMatcher("src/*.ts");
match("src/index.ts"); // true
match("src/index.js"); // false

Features

Globc supports basic glob features:

  • *: Matches 0 or more characters in a single path part
  • ?: Matches 1 character
  • [...]: Matches a range of characters, similar to a RegExp range. If the first character of the range is ! then it matches any character not in the range
  • **: Matches zero or more directories and subdirectories searching for matches
  • {a,b}: Matches any of the given patterns

Directory scan

Currently this library only supports reading and returning paths as string[] with Node APIs.

import { createMatcher } from "@bit-js/globc";
import { scan, scanSync } from "@bit-js/globc/node";

// Require a matcher to be passed in as args
const match = createMatcher("src/*.ts");

// Promise API
const run = scan(match);
await run("src"); // string[]

// Sync API
const runSync = scanSync(match);
runSync("src");

About

Insanely fast cross-runtime glob matcher

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published