readme: add api usage example
Some checks failed
Deno / test (push) Has been cancelled

This commit is contained in:
Anton Nesterov 2023-02-11 17:33:00 +03:00
parent 5aeff6518e
commit c0ebebb9fd

View file

@ -64,6 +64,28 @@ pickit ./config.ts
Most methods are exported from `mod.ts` and can be used within your code. Read Most methods are exported from `mod.ts` and can be used within your code. Read
the [API documentation](https://deno.land/x/pickit/mod.ts) the [API documentation](https://deno.land/x/pickit/mod.ts)
> All functions are using RegExp to match files. So you need to convert globs
> explicitly. Example:
```typescript
import { githubPick } from "https://deno.land/x/pickit@v0.0.3/mod.ts";
import { globToRegExp, join } from "$std/path/mod.ts";
import { readAll } from "$std/streams/conversion.ts";
for await (
const cssFile of githubPick({
repo: "saadeghi/daisyui",
version: "v2.47.0",
pick: [
globToRegExp("**/src/components/**/*.css"),
],
})
) {
const css = new TextDecoder("utf-8").decode(await readAll(cssFile));
// do something with css
}
```
## License ## License
```text ```text