lodash.capitalize
Advanced tools
Comparing version 4.2.0 to 4.2.1
45
index.js
@@ -40,6 +40,6 @@ /** | ||
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ | ||
var reComplexSymbol = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); | ||
var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); | ||
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ | ||
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']'); | ||
var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']'); | ||
@@ -56,2 +56,24 @@ /** Detect free variable `global` from Node.js. */ | ||
/** | ||
* Converts an ASCII `string` to an array. | ||
* | ||
* @private | ||
* @param {string} string The string to convert. | ||
* @returns {Array} Returns the converted array. | ||
*/ | ||
function asciiToArray(string) { | ||
return string.split(''); | ||
} | ||
/** | ||
* Checks if `string` contains Unicode symbols. | ||
* | ||
* @private | ||
* @param {string} string The string to inspect. | ||
* @returns {boolean} Returns `true` if a symbol is found, else `false`. | ||
*/ | ||
function hasUnicode(string) { | ||
return reHasUnicode.test(string); | ||
} | ||
/** | ||
* Converts `string` to an array. | ||
@@ -64,5 +86,18 @@ * | ||
function stringToArray(string) { | ||
return string.match(reComplexSymbol); | ||
return hasUnicode(string) | ||
? unicodeToArray(string) | ||
: asciiToArray(string); | ||
} | ||
/** | ||
* Converts a Unicode `string` to an array. | ||
* | ||
* @private | ||
* @param {string} string The string to convert. | ||
* @returns {Array} Returns the converted array. | ||
*/ | ||
function unicodeToArray(string) { | ||
return string.match(reUnicode) || []; | ||
} | ||
/** Used for built-in method references. */ | ||
@@ -73,3 +108,3 @@ var objectProto = Object.prototype; | ||
* Used to resolve the | ||
* [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) | ||
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) | ||
* of values. | ||
@@ -162,3 +197,3 @@ */ | ||
var strSymbols = reHasComplexSymbol.test(string) | ||
var strSymbols = hasUnicode(string) | ||
? stringToArray(string) | ||
@@ -165,0 +200,0 @@ : undefined; |
{ | ||
"name": "lodash.capitalize", | ||
"version": "4.2.0", | ||
"version": "4.2.1", | ||
"description": "The lodash method `_.capitalize` exported as a module.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://lodash.com/", |
@@ -1,2 +0,2 @@ | ||
# lodash.capitalize v4.2.0 | ||
# lodash.capitalize v4.2.1 | ||
@@ -18,2 +18,2 @@ The [lodash](https://lodash.com/) method `_.capitalize` exported as a [Node.js](https://nodejs.org/) module. | ||
See the [documentation](https://lodash.com/docs#capitalize) or [package source](https://github.com/lodash/lodash/blob/4.2.0-npm-packages/lodash.capitalize) for more details. | ||
See the [documentation](https://lodash.com/docs#capitalize) or [package source](https://github.com/lodash/lodash/blob/4.2.1-npm-packages/lodash.capitalize) for more details. |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
11868
288
0