@ptolemy2002/regex-utils 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/index.js +5 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,9 +4,9 @@ This library contains utilities that are useful when working with JavaScript reg
|
|
|
4
4
|
The functions are not exported as default, so you can import them in one of the following ways:
|
|
5
5
|
```
|
|
6
6
|
// ES6
|
|
7
|
-
import { functionName } from '@ptolemy2002/
|
|
7
|
+
import { functionName } from '@ptolemy2002/regex-utils';
|
|
8
8
|
// CommonJS
|
|
9
|
-
const { functionName } = require('@ptolemy2002/
|
|
9
|
+
const { functionName } = require('@ptolemy2002/regex-utils');
|
|
10
10
|
```
|
|
11
11
|
|
|
12
12
|
## Functions
|
package/index.js
CHANGED
|
@@ -117,8 +117,11 @@ function transformRegex(value, { flags = "", accentInsensitive = false, caseInse
|
|
|
117
117
|
if (accentInsensitive) value = regexAccentInsensitive(value, flags);
|
|
118
118
|
if (caseInsensitive) value = regexCaseInsensitive(value, flags);
|
|
119
119
|
if (matchWhole) value = regexMatchWhole(value, flags);
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
if (value instanceof RegExp) {
|
|
121
|
+
value = new RegExp(value.source, combineFlags(value.flags, flags));
|
|
122
|
+
} else {
|
|
123
|
+
value = new RegExp(value, flags);
|
|
124
|
+
}
|
|
122
125
|
return value;
|
|
123
126
|
}
|
|
124
127
|
function isValidRegex(value, flags = "") {
|