Skip to content

Commit 1b5f670

Browse files
committed
2 parents 0167350 + 1962378 commit 1b5f670

4 files changed

+19
-17
lines changed

VerbalExpressions.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343

4444
// Define the class methods.
4545
VerbalExpression.prototype = {
46-
4746
// Variables to hold the whole
4847
// expression construction in order
4948
_prefixes: '',
@@ -55,6 +54,7 @@
5554
// anything safely to the expression
5655
sanitize: function sanitize(value) {
5756
var reRegExpEscape;
57+
5858
if (value.source) {
5959
return value.source;
6060
}
@@ -201,6 +201,7 @@
201201
anyOf: function anyOf(value) {
202202
value = this.sanitize(value);
203203
this.add('[' + value + ']');
204+
204205
return this;
205206
},
206207

dist/verbalexpressions.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343

4444
// Define the class methods.
4545
VerbalExpression.prototype = {
46-
4746
// Variables to hold the whole
4847
// expression construction in order
4948
_prefixes: '',
@@ -55,6 +54,7 @@
5554
// anything safely to the expression
5655
sanitize: function sanitize(value) {
5756
var reRegExpEscape;
57+
5858
if (value.source) {
5959
return value.source;
6060
}
@@ -201,6 +201,7 @@
201201
anyOf: function anyOf(value) {
202202
value = this.sanitize(value);
203203
this.add('[' + value + ']');
204+
204205
return this;
205206
},
206207

@@ -301,20 +302,20 @@
301302
// between n and m times.
302303
repeatPrevious: function repeatPrevious() {
303304
var value;
304-
var values;
305-
var i;
306-
if (arguments.length <= 1) {
307-
if (/\d+/.exec(arguments[0]) !== null) {
308-
value = '{' + arguments[0] + '}';
309-
}
310-
} else {
311-
values = [];
312-
for (i = 0; i < arguments.length; i++) {
313-
if (/\d+/.exec(arguments[i]) !== null) {
314-
values.push(arguments[i]);
315-
}
305+
var reIsInteger = /\d+/;
306+
var length = arguments.length;
307+
var values = new Array(length);
308+
var i = 0;
309+
var j = 0;
310+
for (i = 0; i < length; i++) {
311+
if (reIsInteger.test(arguments[i])) {
312+
values[j++] = arguments[i];
316313
}
314+
}
317315

316+
if (j > 0) {
317+
// Set the new length of the array, thus reducing to the elements that have content
318+
values.length = j;
318319
value = '{' + values.join(',') + '}';
319320
}
320321

dist/verbalexpressions.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/verbalexpressions.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)