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 b46922f commit 6e14856
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 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 _minLength = mode === "split" ? 1 : 0;
var _maxLength = str.length;

for (var _i = 0; _i < regexes.length; _i++) {
var _regex = regexes[_i];
Expand All @@ -40,15 +42,12 @@ 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;

// A successfull split must return an array with at least two items
if ((_currentMatch || []).length > _minLength) {
if (highestPosition === true) {
// No previous match?
Expand Down Expand Up @@ -91,7 +90,7 @@ var loopRegexes = function(
* @return {string} The trimed string
*/
var trimString = function(str) {
return ((str || "").trim() || null)
return ((str || "").trim() || "");
}


Expand Down

0 comments on commit 6e14856

Please sign in to comment.