Skip to content

Commit

Permalink
feat(std/path): Improve globToRegExp()
Browse files Browse the repository at this point in the history
- feat: Support escaping glob characters
- feat: Support more character classes
- feat: Match characters literally on segment parse failure
- fix: Match nothing for empty globs
- fix: Contain any glob syntax to its path segment
- perf: Remove extraneous separators from generated regex
- doc: Add detailed JSDoc
- chore: Remove old copyright headers
  • Loading branch information
nayeemrmn committed Aug 26, 2020
1 parent 6d964fc commit fb5ffc8
Show file tree
Hide file tree
Showing 3 changed files with 340 additions and 221 deletions.
26 changes: 13 additions & 13 deletions std/fs/expand_glob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,17 @@ function comparePath(a: WalkEntry, b: WalkEntry): number {
return 0;
}

/**
* Expand the glob string from the specified `root` directory and yield each
/** Expand the glob string from the specified `root` directory and yield each
* result as a `WalkEntry` object.
*
* Examples:
* See [`globToRegExp()`](../path/glob.ts#globToRegExp) for details on supported
* syntax.
*
* for await (const file of expandGlob("**\/*.ts")) {
* console.log(file);
* }
* Example:
*
* for await (const file of expandGlob("**\/*.ts")) {
* console.log(file);
* }
*/
export async function* expandGlob(
glob: string,
Expand Down Expand Up @@ -167,15 +169,13 @@ export async function* expandGlob(
yield* currentMatches;
}

/**
* Synchronous version of `expandGlob()`.
/** Synchronous version of `expandGlob()`.
*
* Examples:
* Example:
*
* for (const file of expandGlobSync("**\/*.ts")) {
* console.log(file);
* }
*/
* for (const file of expandGlobSync("**\/*.ts")) {
* console.log(file);
* } */
export function* expandGlobSync(
glob: string,
{
Expand Down
Loading

0 comments on commit fb5ffc8

Please sign in to comment.