Skip to content

Commit

Permalink
Optim
Browse files Browse the repository at this point in the history
  • Loading branch information
eliottvincent committed Dec 3, 2023
1 parent 5b0e525 commit 3074c30
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ var loopRegexes = function(
regexes, str, mode = "match", highestPosition = true
) {
var _match;
var _maxLength = str.length;
var _minLength = mode === "split" ? 1 : 0;

for (var _i = 0; _i < regexes.length; _i++) {
var _regex = regexes[_i];
Expand All @@ -40,14 +42,11 @@ var loopRegexes = function(
_match = _currentMatch;

// A successfull replace must return a smaller string than the input
var _maxLength = str.length;

if (_match.length < _maxLength) {
break;
}
} else if (mode === "split" || mode === "match") {
// A successfull split must return an array with at least two items
var _minLength = mode === "split" ? 1 : 0;

if ((_currentMatch || []).length > _minLength) {
if (highestPosition === true) {
Expand Down

0 comments on commit 3074c30

Please sign in to comment.