@ericcornelissen/lregexp 1.0.3 → 1.0.5
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/index.cjs +2 -6
- package/index.d.ts +3 -0
- package/index.js +2 -6
- package/is-supported-regexp-flag.cjs +9 -9
- package/package.json +8 -1
package/index.cjs
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
const isSupportedRegexpFlag = require("./is-supported-regexp-flag.cjs");
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
let lRegExp = RegExp;
|
|
4
4
|
|
|
5
|
-
let lRegExp;
|
|
6
5
|
if (isSupportedRegexpFlag("l")) {
|
|
6
|
+
const RegExp_ = globalThis.RegExp;
|
|
7
7
|
lRegExp = function(pattern, flags="") {
|
|
8
8
|
return new RegExp_(pattern, `${flags}l`);
|
|
9
9
|
};
|
|
10
|
-
} else {
|
|
11
|
-
lRegExp = function(pattern, flags) {
|
|
12
|
-
return new RegExp_(pattern, flags);
|
|
13
|
-
};
|
|
14
10
|
}
|
|
15
11
|
|
|
16
12
|
module.exports = lRegExp;
|
package/index.d.ts
ADDED
package/index.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import isSupportedRegexpFlag from "is-supported-regexp-flag";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
let lRegExp = RegExp;
|
|
4
4
|
|
|
5
|
-
let lRegExp;
|
|
6
5
|
if (isSupportedRegexpFlag("l")) {
|
|
6
|
+
const RegExp_ = globalThis.RegExp;
|
|
7
7
|
lRegExp = function(pattern, flags="") {
|
|
8
8
|
return new RegExp_(pattern, `${flags}l`);
|
|
9
9
|
};
|
|
10
|
-
} else {
|
|
11
|
-
lRegExp = function(pattern, flags) {
|
|
12
|
-
return new RegExp_(pattern, flags);
|
|
13
|
-
};
|
|
14
10
|
}
|
|
15
11
|
|
|
16
12
|
export default lRegExp;
|
|
@@ -10,17 +10,17 @@
|
|
|
10
10
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
// The above copyright
|
|
14
|
-
//
|
|
15
|
-
//
|
|
13
|
+
// The above copyright notice is from npm:is-supported-regexp-flag@2.0.0 (see
|
|
14
|
+
// <https://www.npmjs.com/package/is-supported-regexp-flag>), which only has an
|
|
15
|
+
// ESM version of the code. This file contains a CommonJS version of that.
|
|
16
16
|
|
|
17
17
|
function isSupportedRegexpFlag(flag) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
try {
|
|
19
|
+
new RegExp("", flag);
|
|
20
|
+
return true;
|
|
21
|
+
} catch {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
module.exports = isSupportedRegexpFlag;
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ericcornelissen/lregexp",
|
|
3
3
|
"description": "Transparently create linear-time regular expressions",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.5",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
|
+
"types": "./index.d.ts",
|
|
9
10
|
"import": "./index.js",
|
|
10
11
|
"require": "./index.cjs"
|
|
11
12
|
}
|
|
@@ -17,6 +18,9 @@
|
|
|
17
18
|
"type": "git",
|
|
18
19
|
"url": "git+https://github.com/ericcornelissen/lregexp.git"
|
|
19
20
|
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": "^12.20.0 || ^14.13.0 || ^15 || ^16 || ^17 || ^18 || ^19 || ^20 || ^21 || ^22 || ^23 || ^24 || ^25"
|
|
23
|
+
},
|
|
20
24
|
"author": {
|
|
21
25
|
"name": "Eric Cornelissen",
|
|
22
26
|
"email": "ericornelissen@gmail.com",
|
|
@@ -30,5 +34,8 @@
|
|
|
30
34
|
],
|
|
31
35
|
"dependencies": {
|
|
32
36
|
"is-supported-regexp-flag": "^2.0.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"tinybench": "6.0.0"
|
|
33
40
|
}
|
|
34
41
|
}
|