@ndlib/ndlib-cdk2 1.0.35 → 1.0.36

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.
@@ -104,12 +104,6 @@ This module is proudly supported by my [Sponsors](https://github.com/juliangrube
104
104
 
105
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
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
107
  ## License
114
108
 
115
109
  (MIT)
@@ -1,3 +1,4 @@
1
+ var concatMap = require('concat-map');
1
2
  var balanced = require('balanced-match');
2
3
 
3
4
  module.exports = expandTop;
@@ -78,6 +79,10 @@ function expandTop(str) {
78
79
  return expand(escapeBraces(str), true).map(unescapeBraces);
79
80
  }
80
81
 
82
+ function identity(e) {
83
+ return e;
84
+ }
85
+
81
86
  function embrace(str) {
82
87
  return '{' + str + '}';
83
88
  }
@@ -96,7 +101,42 @@ function expand(str, isTop) {
96
101
  var expansions = [];
97
102
 
98
103
  var m = balanced('{', '}', str);
99
- if (!m) return [str];
104
+ if (!m || /\$$/.test(m.pre)) return [str];
105
+
106
+ var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
107
+ var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
108
+ var isSequence = isNumericSequence || isAlphaSequence;
109
+ var isOptions = m.body.indexOf(',') >= 0;
110
+ if (!isSequence && !isOptions) {
111
+ // {a},b}
112
+ if (m.post.match(/,(?!,).*\}/)) {
113
+ str = m.pre + '{' + m.body + escClose + m.post;
114
+ return expand(str);
115
+ }
116
+ return [str];
117
+ }
118
+
119
+ var n;
120
+ if (isSequence) {
121
+ n = m.body.split(/\.\./);
122
+ } else {
123
+ n = parseCommaParts(m.body);
124
+ if (n.length === 1) {
125
+ // x{{a,b}}y ==> x{a}y x{b}y
126
+ n = expand(n[0], false).map(embrace);
127
+ if (n.length === 1) {
128
+ var post = m.post.length
129
+ ? expand(m.post, false)
130
+ : [''];
131
+ return post.map(function(p) {
132
+ return m.pre + n[0] + p;
133
+ });
134
+ }
135
+ }
136
+ }
137
+
138
+ // at this point, n is the parts, and we know it's not a comma set
139
+ // with a single entry.
100
140
 
101
141
  // no need to expand pre, since it is guaranteed to be free of brace-sets
102
142
  var pre = m.pre;
@@ -104,97 +144,55 @@ function expand(str, isTop) {
104
144
  ? expand(m.post, false)
105
145
  : [''];
106
146
 
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
- }
147
+ var N;
148
+
149
+ if (isSequence) {
150
+ var x = numeric(n[0]);
151
+ var y = numeric(n[1]);
152
+ var width = Math.max(n[0].length, n[1].length)
153
+ var incr = n.length == 3
154
+ ? Math.abs(numeric(n[2]))
155
+ : 1;
156
+ var test = lte;
157
+ var reverse = y < x;
158
+ if (reverse) {
159
+ incr *= -1;
160
+ test = gte;
140
161
  }
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
- }
162
+ var pad = n.some(isPadded);
163
+
164
+ N = [];
165
+
166
+ for (var i = x; test(i, y); i += incr) {
167
+ var c;
168
+ if (isAlphaSequence) {
169
+ c = String.fromCharCode(i);
170
+ if (c === '\\')
171
+ c = '';
172
+ } else {
173
+ c = String(i);
174
+ if (pad) {
175
+ var need = width - c.length;
176
+ if (need > 0) {
177
+ var z = new Array(need + 1).join('0');
178
+ if (i < 0)
179
+ c = '-' + z + c.slice(1);
180
+ else
181
+ c = z + c;
180
182
  }
181
183
  }
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
184
  }
185
+ N.push(c);
190
186
  }
187
+ } else {
188
+ N = concatMap(n, function(el) { return expand(el, false) });
189
+ }
191
190
 
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
- }
191
+ for (var j = 0; j < N.length; j++) {
192
+ for (var k = 0; k < post.length; k++) {
193
+ var expansion = pre + N[j] + post[k];
194
+ if (!isTop || isSequence || expansion)
195
+ expansions.push(expansion);
198
196
  }
199
197
  }
200
198
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "brace-expansion",
3
3
  "description": "Brace expansion as known from sh/bash",
4
- "version": "2.0.1",
4
+ "version": "1.1.12",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git://github.com/juliangruber/brace-expansion.git"
@@ -14,10 +14,11 @@
14
14
  "bench": "matcha test/perf/bench.js"
15
15
  },
16
16
  "dependencies": {
17
- "balanced-match": "^1.0.0"
17
+ "balanced-match": "^1.0.0",
18
+ "concat-map": "0.0.1"
18
19
  },
19
20
  "devDependencies": {
20
- "@c4312/matcha": "^1.3.1",
21
+ "matcha": "^0.7.0",
21
22
  "tape": "^4.6.0"
22
23
  },
23
24
  "keywords": [],
@@ -42,5 +43,8 @@
42
43
  "iphone/6.0..latest",
43
44
  "android-browser/4.2..latest"
44
45
  ]
46
+ },
47
+ "publishConfig": {
48
+ "tag": "1.x"
45
49
  }
46
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndlib/ndlib-cdk2",
3
- "version": "1.0.35",
3
+ "version": "1.0.36",
4
4
  "description": "Reusable CDK2 modules used within Hesburgh Libraries of Notre Dame",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",