Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add docs for the new
unicode-sets-regex
plugins
- Loading branch information
1 parent
cfc7b59
commit f5b32dc
Showing
2 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
id: babel-plugin-proposal-unicode-sets-regex | ||
title: @babel/plugin-proposal-unicode-sets-regex | ||
sidebar_label: unicode-sets-regex | ||
--- | ||
|
||
This plugins transform regular expression using the `v` flag, introduced by the [RegExp set notation + properties of strings](https://github.com/tc39/proposal-regexp-set-notation) proposal, to regular expressions that use the `u` flag. | ||
|
||
## Example | ||
|
||
```js | ||
/[\p{ASCII}&&\p{Decimal_Number}]/v | ||
``` | ||
|
||
will be transformed to | ||
|
||
```js | ||
/[0-9]/u | ||
``` | ||
|
||
## Installation | ||
|
||
```sh | ||
npm install --save-dev @babel/plugin-proposal-unicode-sets-regex | ||
``` | ||
|
||
## Usage | ||
|
||
### With a configuration file (Recommended) | ||
|
||
```json | ||
{ | ||
"plugins": ["@babel/plugin-proposal-unicode-sets-regex"] | ||
} | ||
``` | ||
|
||
### Via CLI | ||
|
||
```sh | ||
babel --plugins @babel/plugin-proposal-unicode-sets-regex script.js | ||
``` | ||
|
||
### Via Node API | ||
|
||
```javascript | ||
require("@babel/core").transformSync("code", { | ||
plugins: ["@babel/plugin-proposal-unicode-sets-regex"], | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
id: babel-plugin-syntax-unicode-sets-regex | ||
title: @babel/plugin-syntax-unicode-sets-regex | ||
sidebar_label: unicode-sets-regex | ||
--- | ||
|
||
> #### Syntax only | ||
> | ||
> It's unlikely you want to use this plugin directly as it only enables Babel to parse this syntax. Instead, use [plugin-proposal-unicode-sets-regex](plugin-proposal-unicode-sets-regex.md) to _both_ parse and transform this syntax. | ||
This plugins enabled parsing regular expression using the `v` flag, introduced by the [RegExp set notation + properties of strings](https://github.com/tc39/proposal-regexp-set-notation) proposal, to regular expressions that use the `u` flag. | ||
|
||
## Example | ||
|
||
```js | ||
/[\p{ASCII}&&\p{Decimal_Number}]/v | ||
``` | ||
|
||
## Installation | ||
|
||
```sh | ||
npm install --save-dev @babel/plugin-syntax-unicode-sets-regex | ||
``` | ||
|
||
## Usage | ||
|
||
### With a configuration file (Recommended) | ||
|
||
```json | ||
{ | ||
"plugins": ["@babel/plugin-syntax-unicode-sets-regex"] | ||
} | ||
``` | ||
|
||
### Via CLI | ||
|
||
```sh | ||
babel --plugins @babel/plugin-syntax-unicode-sets-regex script.js | ||
``` | ||
|
||
### Via Node API | ||
|
||
```javascript | ||
require("@babel/core").transformSync("code", { | ||
plugins: ["@babel/plugin-syntax-unicode-sets-regex"], | ||
}); | ||
``` |