cdk8s-plus-33 2.4.30 → 2.4.32

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.
Files changed (63) hide show
  1. package/.jsii +4 -4
  2. package/lib/api-resource.js +2 -2
  3. package/lib/base.js +2 -2
  4. package/lib/config-map.js +1 -1
  5. package/lib/container.js +6 -6
  6. package/lib/cron-job.js +1 -1
  7. package/lib/daemon-set.js +1 -1
  8. package/lib/deployment.js +3 -3
  9. package/lib/handler.js +1 -1
  10. package/lib/horizontal-pod-autoscaler.js +4 -4
  11. package/lib/imports/k8s.js +173 -173
  12. package/lib/ingress.js +2 -2
  13. package/lib/job.js +1 -1
  14. package/lib/namespace.js +2 -2
  15. package/lib/network-policy.js +3 -3
  16. package/lib/pod.js +16 -16
  17. package/lib/probe.js +1 -1
  18. package/lib/pv.js +4 -4
  19. package/lib/pvc.js +1 -1
  20. package/lib/role-binding.js +4 -4
  21. package/lib/role.js +2 -2
  22. package/lib/secret.js +6 -6
  23. package/lib/service-account.js +1 -1
  24. package/lib/service.js +1 -1
  25. package/lib/stateful-set.js +2 -2
  26. package/lib/volume.js +1 -1
  27. package/lib/workload.js +2 -2
  28. package/node_modules/balanced-match/.github/FUNDING.yml +2 -0
  29. package/node_modules/balanced-match/LICENSE.md +1 -3
  30. package/node_modules/balanced-match/README.md +55 -15
  31. package/node_modules/balanced-match/index.js +62 -0
  32. package/node_modules/balanced-match/package.json +28 -48
  33. package/node_modules/brace-expansion/.github/FUNDING.yml +2 -0
  34. package/node_modules/brace-expansion/LICENSE +1 -3
  35. package/node_modules/brace-expansion/README.md +62 -21
  36. package/node_modules/brace-expansion/index.js +203 -0
  37. package/node_modules/brace-expansion/package.json +36 -51
  38. package/node_modules/minimatch/dist/commonjs/index.js +5 -2
  39. package/node_modules/minimatch/dist/commonjs/index.js.map +1 -1
  40. package/node_modules/minimatch/dist/esm/index.js +1 -1
  41. package/node_modules/minimatch/dist/esm/index.js.map +1 -1
  42. package/node_modules/minimatch/package.json +3 -2
  43. package/package.json +6 -6
  44. package/node_modules/balanced-match/dist/commonjs/index.d.ts +0 -9
  45. package/node_modules/balanced-match/dist/commonjs/index.d.ts.map +0 -1
  46. package/node_modules/balanced-match/dist/commonjs/index.js +0 -59
  47. package/node_modules/balanced-match/dist/commonjs/index.js.map +0 -1
  48. package/node_modules/balanced-match/dist/commonjs/package.json +0 -3
  49. package/node_modules/balanced-match/dist/esm/index.d.ts +0 -9
  50. package/node_modules/balanced-match/dist/esm/index.d.ts.map +0 -1
  51. package/node_modules/balanced-match/dist/esm/index.js +0 -54
  52. package/node_modules/balanced-match/dist/esm/index.js.map +0 -1
  53. package/node_modules/balanced-match/dist/esm/package.json +0 -3
  54. package/node_modules/brace-expansion/dist/commonjs/index.d.ts +0 -6
  55. package/node_modules/brace-expansion/dist/commonjs/index.d.ts.map +0 -1
  56. package/node_modules/brace-expansion/dist/commonjs/index.js +0 -199
  57. package/node_modules/brace-expansion/dist/commonjs/index.js.map +0 -1
  58. package/node_modules/brace-expansion/dist/commonjs/package.json +0 -3
  59. package/node_modules/brace-expansion/dist/esm/index.d.ts +0 -6
  60. package/node_modules/brace-expansion/dist/esm/index.d.ts.map +0 -1
  61. package/node_modules/brace-expansion/dist/esm/index.js +0 -195
  62. package/node_modules/brace-expansion/dist/esm/index.js.map +0 -1
  63. package/node_modules/brace-expansion/dist/esm/package.json +0 -3
@@ -1,20 +1,22 @@
1
1
  # balanced-match
2
2
 
3
- Match balanced string pairs, like `{` and `}` or `<b>` and
4
- `</b>`. Supports regular expressions as well!
3
+ Match balanced string pairs, like `{` and `}` or `<b>` and `</b>`. Supports regular expressions as well!
4
+
5
+ [![build status](https://secure.travis-ci.org/juliangruber/balanced-match.svg)](http://travis-ci.org/juliangruber/balanced-match)
6
+ [![downloads](https://img.shields.io/npm/dm/balanced-match.svg)](https://www.npmjs.org/package/balanced-match)
7
+
8
+ [![testling badge](https://ci.testling.com/juliangruber/balanced-match.png)](https://ci.testling.com/juliangruber/balanced-match)
5
9
 
6
10
  ## Example
7
11
 
8
12
  Get the first matching pair of braces:
9
13
 
10
14
  ```js
11
- import { balanced } from 'balanced-match'
15
+ var balanced = require('balanced-match');
12
16
 
13
- console.log(balanced('{', '}', 'pre{in{nested}}post'))
14
- console.log(balanced('{', '}', 'pre{first}between{second}post'))
15
- console.log(
16
- balanced(/\s+\{\s+/, /\s+\}\s+/, 'pre { in{nest} } post'),
17
- )
17
+ console.log(balanced('{', '}', 'pre{in{nested}}post'));
18
+ console.log(balanced('{', '}', 'pre{first}between{second}post'));
19
+ console.log(balanced(/\s+\{\s+/, /\s+\}\s+/, 'pre { in{nest} } post'));
18
20
  ```
19
21
 
20
22
  The matches are:
@@ -32,22 +34,22 @@ $ node example.js
32
34
 
33
35
  ## API
34
36
 
35
- ### const m = balanced(a, b, str)
37
+ ### var m = balanced(a, b, str)
36
38
 
37
39
  For the first non-nested matching pair of `a` and `b` in `str`, return an
38
40
  object with those keys:
39
41
 
40
- - **start** the index of the first match of `a`
41
- - **end** the index of the matching `b`
42
- - **pre** the preamble, `a` and `b` not included
43
- - **body** the match, `a` and `b` not included
44
- - **post** the postscript, `a` and `b` not included
42
+ * **start** the index of the first match of `a`
43
+ * **end** the index of the matching `b`
44
+ * **pre** the preamble, `a` and `b` not included
45
+ * **body** the match, `a` and `b` not included
46
+ * **post** the postscript, `a` and `b` not included
45
47
 
46
48
  If there's no match, `undefined` will be returned.
47
49
 
48
50
  If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `['{', 'a', '']` and `{a}}` will match `['', 'a', '}']`.
49
51
 
50
- ### const r = balanced.range(a, b, str)
52
+ ### var r = balanced.range(a, b, str)
51
53
 
52
54
  For the first non-nested matching pair of `a` and `b` in `str`, return an
53
55
  array with indexes: `[ <a index>, <b index> ]`.
@@ -55,3 +57,41 @@ array with indexes: `[ <a index>, <b index> ]`.
55
57
  If there's no match, `undefined` will be returned.
56
58
 
57
59
  If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `[ 1, 3 ]` and `{a}}` will match `[0, 2]`.
60
+
61
+ ## Installation
62
+
63
+ With [npm](https://npmjs.org) do:
64
+
65
+ ```bash
66
+ npm install balanced-match
67
+ ```
68
+
69
+ ## Security contact information
70
+
71
+ To report a security vulnerability, please use the
72
+ [Tidelift security contact](https://tidelift.com/security).
73
+ Tidelift will coordinate the fix and disclosure.
74
+
75
+ ## License
76
+
77
+ (MIT)
78
+
79
+ Copyright (c) 2013 Julian Gruber &lt;julian@juliangruber.com&gt;
80
+
81
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
82
+ this software and associated documentation files (the "Software"), to deal in
83
+ the Software without restriction, including without limitation the rights to
84
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
85
+ of the Software, and to permit persons to whom the Software is furnished to do
86
+ so, subject to the following conditions:
87
+
88
+ The above copyright notice and this permission notice shall be included in all
89
+ copies or substantial portions of the Software.
90
+
91
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
92
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
93
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
94
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
95
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
96
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
97
+ SOFTWARE.
@@ -0,0 +1,62 @@
1
+ 'use strict';
2
+ module.exports = balanced;
3
+ function balanced(a, b, str) {
4
+ if (a instanceof RegExp) a = maybeMatch(a, str);
5
+ if (b instanceof RegExp) b = maybeMatch(b, str);
6
+
7
+ var r = range(a, b, str);
8
+
9
+ return r && {
10
+ start: r[0],
11
+ end: r[1],
12
+ pre: str.slice(0, r[0]),
13
+ body: str.slice(r[0] + a.length, r[1]),
14
+ post: str.slice(r[1] + b.length)
15
+ };
16
+ }
17
+
18
+ function maybeMatch(reg, str) {
19
+ var m = str.match(reg);
20
+ return m ? m[0] : null;
21
+ }
22
+
23
+ balanced.range = range;
24
+ function range(a, b, str) {
25
+ var begs, beg, left, right, result;
26
+ var ai = str.indexOf(a);
27
+ var bi = str.indexOf(b, ai + 1);
28
+ var i = ai;
29
+
30
+ if (ai >= 0 && bi > 0) {
31
+ if(a===b) {
32
+ return [ai, bi];
33
+ }
34
+ begs = [];
35
+ left = str.length;
36
+
37
+ while (i >= 0 && !result) {
38
+ if (i == ai) {
39
+ begs.push(i);
40
+ ai = str.indexOf(a, i + 1);
41
+ } else if (begs.length == 1) {
42
+ result = [ begs.pop(), bi ];
43
+ } else {
44
+ beg = begs.pop();
45
+ if (beg < left) {
46
+ left = beg;
47
+ right = bi;
48
+ }
49
+
50
+ bi = str.indexOf(b, i + 1);
51
+ }
52
+
53
+ i = ai < bi && ai >= 0 ? ai : bi;
54
+ }
55
+
56
+ if (begs.length) {
57
+ result = [ left, right ];
58
+ }
59
+ }
60
+
61
+ return result;
62
+ }
@@ -1,49 +1,20 @@
1
1
  {
2
2
  "name": "balanced-match",
3
3
  "description": "Match balanced character pairs, like \"{\" and \"}\"",
4
- "version": "4.0.4",
5
- "files": [
6
- "dist"
7
- ],
4
+ "version": "1.0.2",
8
5
  "repository": {
9
6
  "type": "git",
10
7
  "url": "git://github.com/juliangruber/balanced-match.git"
11
8
  },
12
- "exports": {
13
- "./package.json": "./package.json",
14
- ".": {
15
- "import": {
16
- "types": "./dist/esm/index.d.ts",
17
- "default": "./dist/esm/index.js"
18
- },
19
- "require": {
20
- "types": "./dist/commonjs/index.d.ts",
21
- "default": "./dist/commonjs/index.js"
22
- }
23
- }
24
- },
25
- "type": "module",
9
+ "homepage": "https://github.com/juliangruber/balanced-match",
10
+ "main": "index.js",
26
11
  "scripts": {
27
- "preversion": "npm test",
28
- "postversion": "npm publish",
29
- "prepublishOnly": "git push origin --follow-tags",
30
- "prepare": "tshy",
31
- "pretest": "npm run prepare",
32
- "presnap": "npm run prepare",
33
- "test": "tap",
34
- "snap": "tap",
35
- "format": "prettier --write .",
36
- "benchmark": "node benchmark/index.js",
37
- "typedoc": "typedoc --tsconfig .tshy/esm.json ./src/*.ts"
12
+ "test": "tape test/test.js",
13
+ "bench": "matcha test/bench.js"
38
14
  },
39
15
  "devDependencies": {
40
- "@types/brace-expansion": "^1.1.2",
41
- "@types/node": "^25.2.1",
42
- "mkdirp": "^3.0.1",
43
- "prettier": "^3.3.2",
44
- "tap": "^21.6.2",
45
- "tshy": "^3.0.2",
46
- "typedoc": "^0.28.5"
16
+ "matcha": "^0.7.0",
17
+ "tape": "^4.6.0"
47
18
  },
48
19
  "keywords": [
49
20
  "match",
@@ -52,17 +23,26 @@
52
23
  "balanced",
53
24
  "parse"
54
25
  ],
55
- "license": "MIT",
56
- "engines": {
57
- "node": "18 || 20 || >=22"
26
+ "author": {
27
+ "name": "Julian Gruber",
28
+ "email": "mail@juliangruber.com",
29
+ "url": "http://juliangruber.com"
58
30
  },
59
- "tshy": {
60
- "exports": {
61
- "./package.json": "./package.json",
62
- ".": "./src/index.ts"
63
- }
64
- },
65
- "main": "./dist/commonjs/index.js",
66
- "types": "./dist/commonjs/index.d.ts",
67
- "module": "./dist/esm/index.js"
31
+ "license": "MIT",
32
+ "testling": {
33
+ "files": "test/*.js",
34
+ "browsers": [
35
+ "ie/8..latest",
36
+ "firefox/20..latest",
37
+ "firefox/nightly",
38
+ "chrome/25..latest",
39
+ "chrome/canary",
40
+ "opera/12..latest",
41
+ "opera/next",
42
+ "safari/5.1..latest",
43
+ "ipad/6.0..latest",
44
+ "iphone/6.0..latest",
45
+ "android-browser/4.2..latest"
46
+ ]
47
+ }
68
48
  }
@@ -0,0 +1,2 @@
1
+ tidelift: "npm/brace-expansion"
2
+ patreon: juliangruber
@@ -1,8 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright Julian Gruber <julian@juliangruber.com>
4
-
5
- TypeScript port Copyright Isaac Z. Schlueter <i@izs.me>
3
+ Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
6
4
 
7
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
8
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,15 +1,18 @@
1
1
  # brace-expansion
2
2
 
3
- [Brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html),
3
+ [Brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html),
4
4
  as known from sh/bash, in JavaScript.
5
5
 
6
- [![CI](https://github.com/juliangruber/brace-expansion/actions/workflows/ci.yml/badge.svg)](https://github.com/juliangruber/brace-expansion/actions/workflows/ci.yml)
6
+ [![build status](https://secure.travis-ci.org/juliangruber/brace-expansion.svg)](http://travis-ci.org/juliangruber/brace-expansion)
7
7
  [![downloads](https://img.shields.io/npm/dm/brace-expansion.svg)](https://www.npmjs.org/package/brace-expansion)
8
+ [![Greenkeeper badge](https://badges.greenkeeper.io/juliangruber/brace-expansion.svg)](https://greenkeeper.io/)
9
+
10
+ [![testling badge](https://ci.testling.com/juliangruber/brace-expansion.png)](https://ci.testling.com/juliangruber/brace-expansion)
8
11
 
9
12
  ## Example
10
13
 
11
14
  ```js
12
- import { expand } from 'brace-expansion'
15
+ var expand = require('brace-expansion');
13
16
 
14
17
  expand('file-{a,b,c}.jpg')
15
18
  // => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg']
@@ -45,36 +48,25 @@ expand('ppp{,config,oe{,conf}}')
45
48
  ## API
46
49
 
47
50
  ```js
48
- import { expand } from '@isaacs/brace-expansion'
51
+ var expand = require('brace-expansion');
49
52
  ```
50
53
 
51
- ### const expanded = expand(str, [options])
52
-
53
- Return an array of all possible and valid expansions of `str`. If
54
- none are found, `[str]` is returned.
55
-
56
- The `options` object can provide a `max` value to cap the number
57
- of expansions allowed. This is limited to `100_000` by default,
58
- to prevent DoS attacks.
54
+ ### var expanded = expand(str)
59
55
 
60
- ```js
61
- const expansions = expand('{1..100}'.repeat(5), {
62
- max: 100,
63
- })
64
- // expansions.length will be 100, not 100^5
65
- ```
56
+ Return an array of all possible and valid expansions of `str`. If none are
57
+ found, `[str]` is returned.
66
58
 
67
59
  Valid expansions are:
68
60
 
69
61
  ```js
70
- ;/^(.*,)+(.+)?$/
62
+ /^(.*,)+(.+)?$/
71
63
  // {a,b,...}
72
64
  ```
73
65
 
74
66
  A comma separated list of options, like `{a,b}` or `{a,{b,c}}` or `{,a,}`.
75
67
 
76
68
  ```js
77
- ;/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
69
+ /^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
78
70
  // {x..y[..incr]}
79
71
  ```
80
72
 
@@ -83,7 +75,7 @@ If `x` or `y` start with a leading `0`, all the numbers will be padded
83
75
  to have equal length. Negative numbers and backwards iteration work too.
84
76
 
85
77
  ```js
86
- ;/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
78
+ /^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
87
79
  // {x..y[..incr]}
88
80
  ```
89
81
 
@@ -92,3 +84,52 @@ An alphabetic sequence from `x` to `y` inclusive, with optional increment.
92
84
  number.
93
85
 
94
86
  For compatibility reasons, the string `${` is not eligible for brace expansion.
87
+
88
+ ## Installation
89
+
90
+ With [npm](https://npmjs.org) do:
91
+
92
+ ```bash
93
+ npm install brace-expansion
94
+ ```
95
+
96
+ ## Contributors
97
+
98
+ - [Julian Gruber](https://github.com/juliangruber)
99
+ - [Isaac Z. Schlueter](https://github.com/isaacs)
100
+
101
+ ## Sponsors
102
+
103
+ This module is proudly supported by my [Sponsors](https://github.com/juliangruber/sponsors)!
104
+
105
+ Do you want to support modules like this to improve their quality, stability and weigh in on new features? Then please consider donating to my [Patreon](https://www.patreon.com/juliangruber). Not sure how much of my modules you're using? Try [feross/thanks](https://github.com/feross/thanks)!
106
+
107
+ ## Security contact information
108
+
109
+ To report a security vulnerability, please use the
110
+ [Tidelift security contact](https://tidelift.com/security).
111
+ Tidelift will coordinate the fix and disclosure.
112
+
113
+ ## License
114
+
115
+ (MIT)
116
+
117
+ Copyright (c) 2013 Julian Gruber &lt;julian@juliangruber.com&gt;
118
+
119
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
120
+ this software and associated documentation files (the "Software"), to deal in
121
+ the Software without restriction, including without limitation the rights to
122
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
123
+ of the Software, and to permit persons to whom the Software is furnished to do
124
+ so, subject to the following conditions:
125
+
126
+ The above copyright notice and this permission notice shall be included in all
127
+ copies or substantial portions of the Software.
128
+
129
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
130
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
131
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
132
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
133
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
134
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
135
+ SOFTWARE.
@@ -0,0 +1,203 @@
1
+ var balanced = require('balanced-match');
2
+
3
+ module.exports = expandTop;
4
+
5
+ var escSlash = '\0SLASH'+Math.random()+'\0';
6
+ var escOpen = '\0OPEN'+Math.random()+'\0';
7
+ var escClose = '\0CLOSE'+Math.random()+'\0';
8
+ var escComma = '\0COMMA'+Math.random()+'\0';
9
+ var escPeriod = '\0PERIOD'+Math.random()+'\0';
10
+
11
+ function numeric(str) {
12
+ return parseInt(str, 10) == str
13
+ ? parseInt(str, 10)
14
+ : str.charCodeAt(0);
15
+ }
16
+
17
+ function escapeBraces(str) {
18
+ return str.split('\\\\').join(escSlash)
19
+ .split('\\{').join(escOpen)
20
+ .split('\\}').join(escClose)
21
+ .split('\\,').join(escComma)
22
+ .split('\\.').join(escPeriod);
23
+ }
24
+
25
+ function unescapeBraces(str) {
26
+ return str.split(escSlash).join('\\')
27
+ .split(escOpen).join('{')
28
+ .split(escClose).join('}')
29
+ .split(escComma).join(',')
30
+ .split(escPeriod).join('.');
31
+ }
32
+
33
+
34
+ // Basically just str.split(","), but handling cases
35
+ // where we have nested braced sections, which should be
36
+ // treated as individual members, like {a,{b,c},d}
37
+ function parseCommaParts(str) {
38
+ if (!str)
39
+ return [''];
40
+
41
+ var parts = [];
42
+ var m = balanced('{', '}', str);
43
+
44
+ if (!m)
45
+ return str.split(',');
46
+
47
+ var pre = m.pre;
48
+ var body = m.body;
49
+ var post = m.post;
50
+ var p = pre.split(',');
51
+
52
+ p[p.length-1] += '{' + body + '}';
53
+ var postParts = parseCommaParts(post);
54
+ if (post.length) {
55
+ p[p.length-1] += postParts.shift();
56
+ p.push.apply(p, postParts);
57
+ }
58
+
59
+ parts.push.apply(parts, p);
60
+
61
+ return parts;
62
+ }
63
+
64
+ function expandTop(str) {
65
+ if (!str)
66
+ return [];
67
+
68
+ // I don't know why Bash 4.3 does this, but it does.
69
+ // Anything starting with {} will have the first two bytes preserved
70
+ // but *only* at the top level, so {},a}b will not expand to anything,
71
+ // but a{},b}c will be expanded to [a}c,abc].
72
+ // One could argue that this is a bug in Bash, but since the goal of
73
+ // this module is to match Bash's rules, we escape a leading {}
74
+ if (str.substr(0, 2) === '{}') {
75
+ str = '\\{\\}' + str.substr(2);
76
+ }
77
+
78
+ return expand(escapeBraces(str), true).map(unescapeBraces);
79
+ }
80
+
81
+ function embrace(str) {
82
+ return '{' + str + '}';
83
+ }
84
+ function isPadded(el) {
85
+ return /^-?0\d/.test(el);
86
+ }
87
+
88
+ function lte(i, y) {
89
+ return i <= y;
90
+ }
91
+ function gte(i, y) {
92
+ return i >= y;
93
+ }
94
+
95
+ function expand(str, isTop) {
96
+ var expansions = [];
97
+
98
+ var m = balanced('{', '}', str);
99
+ if (!m) return [str];
100
+
101
+ // no need to expand pre, since it is guaranteed to be free of brace-sets
102
+ var pre = m.pre;
103
+ var post = m.post.length
104
+ ? expand(m.post, false)
105
+ : [''];
106
+
107
+ if (/\$$/.test(m.pre)) {
108
+ for (var k = 0; k < post.length; k++) {
109
+ var expansion = pre+ '{' + m.body + '}' + post[k];
110
+ expansions.push(expansion);
111
+ }
112
+ } else {
113
+ var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
114
+ var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
115
+ var isSequence = isNumericSequence || isAlphaSequence;
116
+ var isOptions = m.body.indexOf(',') >= 0;
117
+ if (!isSequence && !isOptions) {
118
+ // {a},b}
119
+ if (m.post.match(/,(?!,).*\}/)) {
120
+ str = m.pre + '{' + m.body + escClose + m.post;
121
+ return expand(str);
122
+ }
123
+ return [str];
124
+ }
125
+
126
+ var n;
127
+ if (isSequence) {
128
+ n = m.body.split(/\.\./);
129
+ } else {
130
+ n = parseCommaParts(m.body);
131
+ if (n.length === 1) {
132
+ // x{{a,b}}y ==> x{a}y x{b}y
133
+ n = expand(n[0], false).map(embrace);
134
+ if (n.length === 1) {
135
+ return post.map(function(p) {
136
+ return m.pre + n[0] + p;
137
+ });
138
+ }
139
+ }
140
+ }
141
+
142
+ // at this point, n is the parts, and we know it's not a comma set
143
+ // with a single entry.
144
+ var N;
145
+
146
+ if (isSequence) {
147
+ var x = numeric(n[0]);
148
+ var y = numeric(n[1]);
149
+ var width = Math.max(n[0].length, n[1].length)
150
+ var incr = n.length == 3
151
+ ? Math.abs(numeric(n[2]))
152
+ : 1;
153
+ var test = lte;
154
+ var reverse = y < x;
155
+ if (reverse) {
156
+ incr *= -1;
157
+ test = gte;
158
+ }
159
+ var pad = n.some(isPadded);
160
+
161
+ N = [];
162
+
163
+ for (var i = x; test(i, y); i += incr) {
164
+ var c;
165
+ if (isAlphaSequence) {
166
+ c = String.fromCharCode(i);
167
+ if (c === '\\')
168
+ c = '';
169
+ } else {
170
+ c = String(i);
171
+ if (pad) {
172
+ var need = width - c.length;
173
+ if (need > 0) {
174
+ var z = new Array(need + 1).join('0');
175
+ if (i < 0)
176
+ c = '-' + z + c.slice(1);
177
+ else
178
+ c = z + c;
179
+ }
180
+ }
181
+ }
182
+ N.push(c);
183
+ }
184
+ } else {
185
+ N = [];
186
+
187
+ for (var j = 0; j < n.length; j++) {
188
+ N.push.apply(N, expand(n[j], false));
189
+ }
190
+ }
191
+
192
+ for (var j = 0; j < N.length; j++) {
193
+ for (var k = 0; k < post.length; k++) {
194
+ var expansion = pre + N[j] + post[k];
195
+ if (!isTop || isSequence || expansion)
196
+ expansions.push(expansion);
197
+ }
198
+ }
199
+ }
200
+
201
+ return expansions;
202
+ }
203
+