brace-expansion 3.0.0 → 4.0.0
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.js +20 -10
- package/package.json +1 -1
- package/tea.yaml +6 -0
package/index.js
CHANGED
|
@@ -5,6 +5,16 @@ const escOpen = '\0OPEN' + Math.random() + '\0'
|
|
|
5
5
|
const escClose = '\0CLOSE' + Math.random() + '\0'
|
|
6
6
|
const escComma = '\0COMMA' + Math.random() + '\0'
|
|
7
7
|
const escPeriod = '\0PERIOD' + Math.random() + '\0'
|
|
8
|
+
const escSlashPattern = new RegExp(escSlash, 'g')
|
|
9
|
+
const escOpenPattern = new RegExp(escOpen, 'g')
|
|
10
|
+
const escClosePattern = new RegExp(escClose, 'g')
|
|
11
|
+
const escCommaPattern = new RegExp(escComma, 'g')
|
|
12
|
+
const escPeriodPattern = new RegExp(escPeriod, 'g')
|
|
13
|
+
const slashPattern = /\\\\/g
|
|
14
|
+
const openPattern = /\\{/g
|
|
15
|
+
const closePattern = /\\}/g
|
|
16
|
+
const commaPattern = /\\,/g
|
|
17
|
+
const periodPattern = /\\./g
|
|
8
18
|
|
|
9
19
|
/**
|
|
10
20
|
* @return {number}
|
|
@@ -19,22 +29,22 @@ function numeric (str) {
|
|
|
19
29
|
* @param {string} str
|
|
20
30
|
*/
|
|
21
31
|
function escapeBraces (str) {
|
|
22
|
-
return str.
|
|
23
|
-
.
|
|
24
|
-
.
|
|
25
|
-
.
|
|
26
|
-
.
|
|
32
|
+
return str.replace(slashPattern, escSlash)
|
|
33
|
+
.replace(openPattern, escOpen)
|
|
34
|
+
.replace(closePattern, escClose)
|
|
35
|
+
.replace(commaPattern, escComma)
|
|
36
|
+
.replace(periodPattern, escPeriod)
|
|
27
37
|
}
|
|
28
38
|
|
|
29
39
|
/**
|
|
30
40
|
* @param {string} str
|
|
31
41
|
*/
|
|
32
42
|
function unescapeBraces (str) {
|
|
33
|
-
return str.
|
|
34
|
-
.
|
|
35
|
-
.
|
|
36
|
-
.
|
|
37
|
-
.
|
|
43
|
+
return str.replace(escSlashPattern, '\\')
|
|
44
|
+
.replace(escOpenPattern, '{')
|
|
45
|
+
.replace(escClosePattern, '}')
|
|
46
|
+
.replace(escCommaPattern, ',')
|
|
47
|
+
.replace(escPeriodPattern, '.')
|
|
38
48
|
}
|
|
39
49
|
|
|
40
50
|
/**
|
package/package.json
CHANGED