regexpu-core
Advanced tools
Comparing version 5.1.0 to 5.2.1
{ | ||
"name": "regexpu-core", | ||
"version": "5.1.0", | ||
"version": "5.2.1", | ||
"description": "regexpu’s core functionality (i.e. `rewritePattern(pattern, flag)`), capable of translating ES6 Unicode regular expressions to ES5.", | ||
@@ -52,5 +52,5 @@ "homepage": "https://mths.be/regexpu", | ||
"regenerate": "^1.4.2", | ||
"regenerate-unicode-properties": "^10.0.1", | ||
"regjsgen": "^0.6.0", | ||
"regjsparser": "^0.8.2", | ||
"regenerate-unicode-properties": "^10.1.0", | ||
"regjsgen": "^0.7.1", | ||
"regjsparser": "^0.9.1", | ||
"unicode-match-property-ecmascript": "^2.0.0", | ||
@@ -64,6 +64,6 @@ "unicode-match-property-value-ecmascript": "^2.0.0" | ||
"lodash": "^4.17.21", | ||
"mocha": "^9.1.1", | ||
"mocha": "^10.0.0", | ||
"regexpu-fixtures": "2.1.4", | ||
"@unicode/unicode-14.0.0": "^1.2.1" | ||
"@unicode/unicode-15.0.0": "^1.3.1" | ||
} | ||
} |
@@ -188,3 +188,3 @@ # regexpu-core [![Build status](https://github.com/mathiasbynens/regexpu-core/workflows/run-checks/badge.svg)](https://github.com/mathiasbynens/regexpu-core/actions?query=workflow%3Arun-checks) [![regexpu-core on npm](https://img.shields.io/npm/v/regexpu-core)](https://www.npmjs.com/package/regexpu-core) | ||
```sh | ||
git push && git push --tags | ||
git push --follow-tags | ||
``` | ||
@@ -191,0 +191,0 @@ |
@@ -24,3 +24,3 @@ 'use strict'; | ||
const SPECIAL_CHARS = new Set('\\^$.*+?()[]{}|'.split('')); | ||
const SPECIAL_CHARS = /([\\^$.*+?()[\]{}|])/g; | ||
@@ -113,4 +113,4 @@ // Prepare a Regenerate set containing all code points, used for negative | ||
strings: set.strings | ||
// We need to escape strings like *️⃣ to make sure that they can be safelu used in unions | ||
? new Set(set.strings.map(str => SPECIAL_CHARS.has(str[0]) ? `\\${str}` : str)) | ||
// We need to escape strings like *️⃣ to make sure that they can be safely used in unions. | ||
? new Set(set.strings.map(str => str.replace(SPECIAL_CHARS, '\\$1'))) | ||
: new Set() | ||
@@ -531,3 +531,3 @@ }; | ||
} | ||
if (item.name && config.transform.namedGroups) { | ||
if (item.name) { | ||
const name = item.name.value; | ||
@@ -542,5 +542,7 @@ | ||
if (config.transform.namedGroups) { | ||
delete item.name; | ||
} | ||
const index = groups.lastIndex; | ||
delete item.name; | ||
if (!groups.names[name]) { | ||
@@ -594,27 +596,32 @@ groups.names[name] = []; | ||
const indexes = groups.names[name]; | ||
if (indexes) { | ||
const body = indexes.map(index => ({ | ||
'type': 'reference', | ||
'matchIndex': index, | ||
'raw': '\\' + index, | ||
})); | ||
if (body.length === 1) { | ||
return body[0]; | ||
if (!indexes) { | ||
groups.unmatchedReferences[name] = true; | ||
} | ||
if (config.transform.namedGroups) { | ||
if (indexes) { | ||
const body = indexes.map(index => ({ | ||
'type': 'reference', | ||
'matchIndex': index, | ||
'raw': '\\' + index, | ||
})); | ||
if (body.length === 1) { | ||
return body[0]; | ||
} | ||
return { | ||
'type': 'alternative', | ||
'body': body, | ||
'raw': body.map(term => term.raw).join(''), | ||
}; | ||
} | ||
// This named reference comes before the group where it’s defined, | ||
// so it’s always an empty match. | ||
return { | ||
'type': 'alternative', | ||
'body': body, | ||
'raw': body.map(term => term.raw).join(''), | ||
'type': 'group', | ||
'behavior': 'ignore', | ||
'body': [], | ||
'raw': '(?:)', | ||
}; | ||
} | ||
// This named reference comes before the group where it’s defined, | ||
// so it’s always an empty match. | ||
groups.unmatchedReferences[name] = true; | ||
return { | ||
'type': 'group', | ||
'behavior': 'ignore', | ||
'body': [], | ||
'raw': '(?:)', | ||
}; | ||
} | ||
@@ -621,0 +628,0 @@ break; |
47851
1436
+ Addedregjsgen@0.7.1(transitive)
+ Addedregjsparser@0.9.1(transitive)
- Removedregjsgen@0.6.0(transitive)
- Removedregjsparser@0.8.4(transitive)
Updatedregjsgen@^0.7.1
Updatedregjsparser@^0.9.1