From 7374f6dc4f66d37bd773306820946ba0905ffa96 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 22 Jun 2014 14:57:37 -0700 Subject: [PATCH] Simplify `charsLeftIndex` and `charsRightIndex`. --- lodash.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/lodash.js b/lodash.js index 4d9bc1944..83929da2b 100644 --- a/lodash.js +++ b/lodash.js @@ -384,11 +384,7 @@ var index = -1, length = string.length; - while (++index < length) { - if (chars.indexOf(string.charAt(index)) < 0) { - break; - } - } + while (++index < length && chars.indexOf(string.charAt(index)) > -1) { } return index; } @@ -404,11 +400,7 @@ function charsRightIndex(string, chars) { var index = string.length; - while (index--) { - if (chars.indexOf(string.charAt(index)) < 0) { - break; - } - } + while (index-- && chars.indexOf(string.charAt(index)) > -1) { } return index; }