type-level-regexp
Advanced tools
Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "type-level-regexp", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Type-Level RegExp parser, matcher and permutation resolver", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -27,4 +27,6 @@ # 🔤🔍 Type-Level RegExp (WIP) | ||
2. Import `createRegExp` from `type-level-regexp`, create a `TypedRegExp` and pass it to `String.match` or `String.replace` functions. | ||
2. Import `createRegExp` function from `type-level-regexp`, pass in a RegExp pattern to it creates a `TypedRegExp`, passing this `TypedRegExp` to `String.match` or `String.replace` functions to get fully typed match result. | ||
```ts | ||
## Basic Usage | ||
@@ -56,2 +58,5 @@ match result will be fully typed if match against a literal stirng, or shows emumerated results if match against a dynamic string. | ||
spreadedResult[3].index // 12 | ||
const InvalidRegExp = createRegExp('foo(bar') | ||
// TypeScript error: Argument of type 'string' is not assignable to parameter of type 'RegExpSyntaxError<"Invalid regular expression, missing closing \`)\`">' | ||
``` | ||
@@ -96,3 +101,4 @@ | ||
- Export `createRegExp` function to create a `TypedRegExp` that can be pass to `String` match and replace functions and gets fully typed match result. | ||
- Export `createRegExp` function to create a`TypedRegExp` that replace your original `/regex_pattern/` regex object, which can be pass to `String.match()`, `String.matchAll()` and `String.replace()` functions and gets fully typed result. | ||
- Shows `RegExpSyntaxError` if the provided RegExp pattern is invalid. | ||
- Enhance types of RegExp related `String` functions (`.match`, `matchAll`, `.replace`...) for literal or dynamic typed string. | ||
@@ -108,4 +114,2 @@ - Result of `String` functions matched exactly as runtime result. | ||
That's it! You can now use Tailwind classes in your Nuxt app ✨ | ||
#### Example - type-safe args in replacing function of `string.replace()` | ||
@@ -112,0 +116,0 @@ ![replaceRegexp](https://user-images.githubusercontent.com/29917252/224333879-50d51207-f63c-4ac6-b561-34ace9ebb7d4.JPG) |
Sorry, the diff of this file is too big to display
80460
1175
165