mirror of
https://github.com/denoland/deno.git
synced 2024-12-03 17:08:35 -05:00
docs: document and add examples of expandGlob (#6404)
This commit is contained in:
parent
3c58767831
commit
c0ea9a99c0
2 changed files with 40 additions and 1 deletions
|
@ -196,3 +196,28 @@ import {
|
||||||
writeFileStr("./target.dat", "file content"); // returns a promise
|
writeFileStr("./target.dat", "file content"); // returns a promise
|
||||||
writeFileStrSync("./target.dat", "file content"); // void
|
writeFileStrSync("./target.dat", "file content"); // void
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### expandGlob
|
||||||
|
|
||||||
|
Expand the glob string from the specified `root` directory and yield each result
|
||||||
|
as a `WalkEntry` object.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { expandGlob } from "https://deno.land/std/fs/mod.ts";
|
||||||
|
|
||||||
|
for await (const file of expandGlob("**/*.ts")) {
|
||||||
|
console.log(file);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### expandGlobSync
|
||||||
|
|
||||||
|
Synchronous version of `expandGlob()`.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { expandGlobSync } from "https://deno.land/std/fs/mod.ts";
|
||||||
|
|
||||||
|
for (const file of expandGlobSync("**/*.ts")) {
|
||||||
|
console.log(file);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
|
@ -62,6 +62,12 @@ function comparePath(a: WalkEntry, b: WalkEntry): number {
|
||||||
/**
|
/**
|
||||||
* 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.
|
* result as a `WalkEntry` object.
|
||||||
|
*
|
||||||
|
* Examples:
|
||||||
|
*
|
||||||
|
* for await (const file of expandGlob("**\/*.ts")) {
|
||||||
|
* console.log(file);
|
||||||
|
* }
|
||||||
*/
|
*/
|
||||||
export async function* expandGlob(
|
export async function* expandGlob(
|
||||||
glob: string,
|
glob: string,
|
||||||
|
@ -161,7 +167,15 @@ export async function* expandGlob(
|
||||||
yield* currentMatches;
|
yield* currentMatches;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Synchronous version of `expandGlob()`. */
|
/**
|
||||||
|
* Synchronous version of `expandGlob()`.
|
||||||
|
*
|
||||||
|
* Examples:
|
||||||
|
*
|
||||||
|
* for (const file of expandGlobSync("**\/*.ts")) {
|
||||||
|
* console.log(file);
|
||||||
|
* }
|
||||||
|
*/
|
||||||
export function* expandGlobSync(
|
export function* expandGlobSync(
|
||||||
glob: string,
|
glob: string,
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue