mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 10:17:48 +00:00
Fixed comment typo and refactored duplicate code.
This commit is contained in:
committed by
John-David Dalton
parent
f77586f13d
commit
2f98cd9eb0
22
lodash.js
22
lodash.js
@@ -69,7 +69,7 @@
|
|||||||
/** Used to match `RegExp` flags from their coerced string values */
|
/** Used to match `RegExp` flags from their coerced string values */
|
||||||
var reFlags = /\w*$/;
|
var reFlags = /\w*$/;
|
||||||
|
|
||||||
/** Used to detected named functions */
|
/** Used to detect named functions */
|
||||||
var reFuncName = /^\s*function[ \n\r\t]+\w/;
|
var reFuncName = /^\s*function[ \n\r\t]+\w/;
|
||||||
|
|
||||||
/** Used to detect hexadecimal string values */
|
/** Used to detect hexadecimal string values */
|
||||||
@@ -528,6 +528,18 @@
|
|||||||
return typeof value.toString != 'function' && typeof (value + '') == 'string';
|
return typeof value.toString != 'function' && typeof (value + '') == 'string';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used by `_.trimmedLeftIndex` and `_.trimmedRightIndex` to determine if a charCode is whitespace.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {number} c The charCode to inspect.
|
||||||
|
* @returns {number} Returns the index of the first non-whitespace character.
|
||||||
|
*/
|
||||||
|
function isWhitespace(c) {
|
||||||
|
return ((c <= 160 && (c >= 9 && c <= 13) || c == 32 || c == 160) || c == 5760 || c == 6158 ||
|
||||||
|
(c >= 8192 && (c <= 8202 || c == 8232 || c == 8233 || c == 8239 || c == 8287 || c == 12288 || c == 65279)));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used by `_.trim` and `_.trimLeft` to get the index of the first non-whitespace
|
* Used by `_.trim` and `_.trimLeft` to get the index of the first non-whitespace
|
||||||
* character of `string`.
|
* character of `string`.
|
||||||
@@ -541,9 +553,7 @@
|
|||||||
length = string.length;
|
length = string.length;
|
||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
var c = string.charCodeAt(index);
|
if (!isWhitespace(string.charCodeAt(index))) {
|
||||||
if (!((c <= 160 && (c >= 9 && c <= 13) || c == 32 || c == 160) || c == 5760 || c == 6158 ||
|
|
||||||
(c >= 8192 && (c <= 8202 || c == 8232 || c == 8233 || c == 8239 || c == 8287 || c == 12288 || c == 65279)))) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -562,9 +572,7 @@
|
|||||||
var index = string.length;
|
var index = string.length;
|
||||||
|
|
||||||
while (index--) {
|
while (index--) {
|
||||||
var c = string.charCodeAt(index);
|
if (!isWhitespace(string.charCodeAt(index))) {
|
||||||
if (!((c <= 160 && (c >= 9 && c <= 13) || c == 32 || c == 160) || c == 5760 || c == 6158 ||
|
|
||||||
(c >= 8192 && (c <= 8202 || c == 8232 || c == 8233 || c == 8239 || c == 8287 || c == 12288 || c == 65279)))) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user