Skip to content

Commit 643bc4b

Browse files
committed
continuu
1 parent 3943391 commit 643bc4b

5 files changed

Lines changed: 46 additions & 24 deletions

File tree

ark/docs/content/docs/blog/arkregex.mdx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ The `regex` function creates a `Regex` instance with types for `.test()`, `.exec
1717
import { regex } from "arkregex"
1818

1919
const ok = regex("^ok$", "i")
20-
// ^ Regex<"ok" | "oK" | "Ok" | "OK", { flags: "i" }>
20+
// Regex<"ok" | "oK" | "Ok" | "OK", { flags: "i" }>
2121

2222
const semver = regex("^(\\d*)\\.(\\d*)\\.(\\d*)$")
23-
// ^ Regex<`${bigint}.${bigint}.${bigint}`, { captures: [`${bigint}`, `${bigint}`, `${bigint}`] }>
23+
// Regex<`${bigint}.${bigint}.${bigint}`, { captures: [`${bigint}`, `${bigint}`, `${bigint}`] }>
2424

2525
const email = regex("^(?<name>\\w+)@(?<domain>\\w+\\.\\w+)$")
26-
// ^ Regex<`${string}@${string}.${string}`, { names: { name: string; domain: `${string}.${string}`; }; ...>
26+
// Regex<`${string}@${string}.${string}`, { names: { name: string; domain: `${string}.${string}`; }; ...>
2727
```
2828

2929
### Features
@@ -53,6 +53,16 @@ const complexPattern = regex.cast<`pattern-${string}`, { captures: [string] }>(
5353
)
5454
```
5555

56+
#### Is it robust?
57+
58+
`arkregex` types are [extensively tested](https://github.com/arktypeio/arktype/tree/main/ark/regex/__tests__/regex.test.ts) and [benchmarked](https://github.com/arktypeio/arktype/tree/main/ark/regex/__tests__/regex.bench.ts) using [attest](https://github.com/arktypeio/arktype/tree/main/ark/attest#readme).
59+
60+
If anything not covered by the other FAQs is not behaving how you'd expect, please don't hesitate to [create an issue](https://github.com/arktypeio/arktype/issues/new).
61+
62+
#### How can I get syntax highlighting for `regex`?
63+
64+
The [ArkType extension](https://marketplace.visualstudio.com/items?itemName=arktypeio.arkdark) can be installed to add syntax highlighting to `regex` calls.
65+
5666
<MainAutoplayDemo />
5767

5868
[Starting coding](/docs/intro/setup)

ark/docs/public/llms.txt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,13 +368,13 @@ The `regex` function creates a `Regex` instance with types for `.test()`, `.exec
368368
import { regex } from "arkregex"
369369

370370
const ok = regex("^ok$", "i")
371-
// ^ Regex<"ok" | "oK" | "Ok" | "OK", { flags: "i" }>
371+
// Regex<"ok" | "oK" | "Ok" | "OK", { flags: "i" }>
372372

373373
const semver = regex("^(\\d*)\\.(\\d*)\\.(\\d*)$")
374-
// ^ Regex<`${bigint}.${bigint}.${bigint}`, { captures: [`${bigint}`, `${bigint}`, `${bigint}`] }>
374+
// Regex<`${bigint}.${bigint}.${bigint}`, { captures: [`${bigint}`, `${bigint}`, `${bigint}`] }>
375375

376376
const email = regex("^(?<name>\\w+)@(?<domain>\\w+\\.\\w+)$")
377-
// ^ Regex<`${string}@${string}.${string}`, { names: { name: string; domain: `${string}.${string}`; }; ...>
377+
// Regex<`${string}@${string}.${string}`, { names: { name: string; domain: `${string}.${string}`; }; ...>
378378
```
379379

380380
### Features
@@ -404,6 +404,16 @@ const complexPattern = regex.cast<`pattern-${string}`, { captures: [string] }>(
404404
)
405405
```
406406

407+
#### Is it robust?
408+
409+
`arkregex` types are [extensively tested](https://github.com/arktypeio/arktype/tree/main/ark/regex/__tests__/regex.test.ts) and [benchmarked](https://github.com/arktypeio/arktype/tree/main/ark/regex/__tests__/regex.bench.ts) using [attest](https://github.com/arktypeio/arktype/tree/main/ark/attest#readme).
410+
411+
If anything not covered by the other FAQs is not behaving how you'd expect, please don't hesitate to [create an issue](https://github.com/arktypeio/arktype/issues/new).
412+
413+
#### How can I get syntax highlighting for `regex`?
414+
415+
The [ArkType extension](https://marketplace.visualstudio.com/items?itemName=arktypeio.arkdark) can be installed to add syntax highlighting to `regex` calls.
416+
407417
<MainAutoplayDemo />
408418

409419
⚡ [Starting coding](/docs/intro/setup)

ark/extension/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
</div>
55
<div align="center">
66

7-
[ArkType](https://arktype.io) syntax highlighting and theme⛵
7+
[ArkType](https://arktype.io) syntax highlighting and inline errors ⛵
8+
9+
[Install the extension](https://marketplace.visualstudio.com/items?itemName=arktypeio.arkdark)
810

911
</div>
1012

ark/regex/README.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,37 @@ A drop-in replacement for `new RegExp()` with types
44

55
## Usage
66

7-
The `regex` function creates a `Regex` instance with types for `.test()`, `.exec()` and more, statically parsed from native JS syntax.
7+
The `regex` function creates a `Regex` instance with types for `.test()`, `.exec()` and more, statically parsed from native JS syntax:
88

99
```ts
1010
import { regex } from "arkregex"
1111

1212
const ok = regex("^ok$", "i")
13-
// ^ Regex<"ok" | "oK" | "Ok" | "OK", { flags: "i" }>
13+
// Regex<"ok" | "oK" | "Ok" | "OK", { flags: "i" }>
1414

1515
const semver = regex("^(\\d*)\\.(\\d*)\\.(\\d*)$")
16-
// ^ Regex<`${bigint}.${bigint}.${bigint}`, { captures: [`${bigint}`, `${bigint}`, `${bigint}`] }>
16+
// Regex<`${bigint}.${bigint}.${bigint}`, { captures: [`${bigint}`, `${bigint}`, `${bigint}`] }>
1717

1818
const email = regex("^(?<name>\\w+)@(?<domain>\\w+\\.\\w+)$")
19-
// ^ Regex<`${string}@${string}.${string}`, { names: { name: string; domain: `${string}.${string}`; }; ...>
19+
// Regex<`${string}@${string}.${string}`, { names: { name: string; domain: `${string}.${string}`; }; ...>
2020
```
2121

22-
## Features
22+
### Features
2323

2424
- **Types**: Infers string types for your existing regular expressions, including positional and named captures
2525
- **Parity**: Supports 100% of [features](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions) allowed by `new RegExp()`
2626
- **Safety**: Syntax errors like referencing a group that doesn't exist are now type errors
27-
- **Zero Runtime**: Improves your type safety without impacting your bundle size[\*](#footnote)
27+
- **Zero Runtime**: Improves your type safety without impacting your bundle size
2828

29-
## FAQ
29+
### FAQ
3030

31-
### Why aren't some patterns like `[a-Z]` inferred more precisely?
31+
#### Why aren't some patterns like `[a-Z]` inferred more precisely?
3232

3333
Constructing string literal types for these sorts of expressions is combinatorial and will explode very quickly if we infer character ranges like this as literal characters.
3434

3535
We've tried to strike a balance between performance and precision while guaranteeing that the inferred types are at worst imprecise and never incorrect.
3636

37-
### Why doesn't it work with my massive RegExp?
37+
#### Why doesn't it work with my massive RegExp?
3838

3939
If your expression is especially long or complex, TypeScript won't be able to infer it.
4040

@@ -46,10 +46,12 @@ const complexPattern = regex.cast<`pattern-${string}`, { captures: [string] }>(
4646
)
4747
```
4848

49-
<a id="footnote"></a>
50-
\*The actual runtime bundle size is two lines:
49+
#### Is it robust?
5150

52-
```ts
53-
export const regex = (src, flags) => new RegExp(src, flags)
54-
Object.assign(regex, { cast: regex })
55-
```
51+
`arkregex` types are [extensively tested](https://github.com/arktypeio/arktype/tree/main/ark/regex/__tests__/regex.test.ts) and [benchmarked](https://github.com/arktypeio/arktype/tree/main/ark/regex/__tests__/regex.bench.ts) using [attest](https://github.com/arktypeio/arktype/tree/main/ark/attest#readme).
52+
53+
If anything not covered by the other FAQs is not behaving how you'd expect, please don't hesitate to [create an issue](https://github.com/arktypeio/arktype/issues/new).
54+
55+
#### How can I get syntax highlighting for `regex`?
56+
57+
The [ArkType extension](https://marketplace.visualstudio.com/items?itemName=arktypeio.arkdark) can be installed to add syntax highlighting to `regex` calls.

ark/regex/__tests__/regex.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,5 +1343,3 @@ contextualize(() => {
13431343
})
13441344
})
13451345
})
1346-
1347-
const ok = regex("^ok$", "i")

0 commit comments

Comments
 (0)