|
18 | 18 | - [Install](#install) |
19 | 19 | - [Use](#use) |
20 | 20 | - [API](#api) |
| 21 | + - [`DECORATOR_REGEX`](#decorator-regex) |
21 | 22 | - [Types](#types) |
22 | 23 | - [Related](#related) |
23 | 24 | - [Contribute](#contribute) |
24 | 25 |
|
25 | 26 | ## What is this? |
26 | 27 |
|
27 | | -This package contains regular expressions for matching [decorators][1]. Decorators are functions called on classes, |
28 | | -class elements, or other JavaScript and TypeScript syntax forms during definition. |
| 28 | +This package exports a regular expression for matching [decorators][1]. Decorators are functions called on classes, |
| 29 | +class accessors, class fields, class methods, and/or class method parameters. |
29 | 30 |
|
30 | 31 | ## When should I use this? |
31 | 32 |
|
32 | | -Regex expressions exported from this package can be used to match decorators in JavaScript and TypeScript source code. |
| 33 | +The regular expression exported from this package can be used to match multi and single-line decorators in JavaScript |
| 34 | +and TypeScript source code. |
33 | 35 |
|
34 | 36 | Note: |
35 | 37 |
|
36 | | -- Statements in docblock (`/** */`), multiline (`/* */`), and single-line (`//`) comments are ignored |
37 | | -- Expressions are ECMAScript-compatible. They have not been tested with other flavors (PCRE, PCRE2, etc) |
| 38 | +- Decorators in comments (`/** */`, `/* */`, `//`) are ignored |
| 39 | +- Regular expression is ECMAScript-compatible. It has **not** been tested with other flavors (PCRE, PCRE2, etc) |
38 | 40 |
|
39 | 41 | ## Install |
40 | 42 |
|
@@ -63,23 +65,39 @@ yarn add @flex-development/decorator-regex@flex-development/decorator-regex |
63 | 65 |
|
64 | 66 | ## API |
65 | 67 |
|
66 | | -**TODO**: api documentation. |
| 68 | +This package exports the identifier [`DECORATOR_REGEX`](#decorator-regex). |
| 69 | + |
| 70 | +There is no default export. |
| 71 | + |
| 72 | +### `DECORATOR_REGEX` |
| 73 | + |
| 74 | +Regular expression matching multi and single-line decorators. |
| 75 | + |
| 76 | +Ignores matches in comments. |
| 77 | + |
| 78 | +Required [flags][3]: |
| 79 | + |
| 80 | +- `s`: dot all |
| 81 | +- `u`: unicode |
| 82 | + |
| 83 | +> **Source**: [`src/decorator-regex.ts`](src/decorator-regex.ts) |
67 | 84 |
|
68 | 85 | ## Types |
69 | 86 |
|
70 | | -This package is fully typed with [TypeScript][3]. |
| 87 | +This package is fully typed with [TypeScript][4]. |
71 | 88 |
|
72 | 89 | ## Related |
73 | 90 |
|
74 | | -- [`export-regex`][4] — `export` statement regex |
75 | | -- [`import-regex`][5] — `import` statement regex |
| 91 | +- [`export-regex`][5] — `export` statement regex |
| 92 | +- [`import-regex`][6] — `import` statement regex |
76 | 93 |
|
77 | 94 | ## Contribute |
78 | 95 |
|
79 | 96 | See [`CONTRIBUTING.md`](CONTRIBUTING.md). |
80 | 97 |
|
81 | 98 | [1]: https://github.com/tc39/proposal-decorators |
82 | 99 | [2]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c |
83 | | -[3]: https://www.typescriptlang.org |
84 | | -[4]: https://github.com/flex-development/export-regex |
85 | | -[5]: https://github.com/flex-development/import-regex |
| 100 | +[3]: https://codeguage.com/courses/regexp/flags |
| 101 | +[4]: https://www.typescriptlang.org |
| 102 | +[5]: https://github.com/flex-development/export-regex |
| 103 | +[6]: https://github.com/flex-development/import-regex |
0 commit comments