lodash.snakecase
Advanced tools
Comparing version 4.1.0 to 4.1.1
104
index.js
@@ -16,7 +16,7 @@ /** | ||
/** Used to match non-compound words composed of alphanumeric characters. */ | ||
var reBasicWord = /[a-zA-Z0-9]+/g; | ||
/** Used to match words composed of alphanumeric characters. */ | ||
var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; | ||
/** Used to match latin-1 supplementary letters (excluding mathematical operators). */ | ||
var reLatin1 = /[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g; | ||
/** Used to match Latin Unicode letters (excluding mathematical operators). */ | ||
var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; | ||
@@ -74,3 +74,3 @@ /** Used to compose unicode character classes. */ | ||
/** Used to match complex or compound words. */ | ||
var reComplexWord = RegExp([ | ||
var reUnicodeWord = RegExp([ | ||
rsUpper + '?' + rsLower + '+' + rsOptLowerContr + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')', | ||
@@ -85,6 +85,7 @@ rsUpperMisc + '+' + rsOptUpperContr + '(?=' + [rsBreak, rsUpper + rsLowerMisc, '$'].join('|') + ')', | ||
/** Used to detect strings that need a more robust regexp to match words. */ | ||
var reHasComplexWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/; | ||
var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/; | ||
/** Used to map latin-1 supplementary letters to basic latin letters. */ | ||
/** Used to map Latin Unicode letters to basic Latin letters. */ | ||
var deburredLetters = { | ||
// Latin-1 Supplement block. | ||
'\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', | ||
@@ -96,4 +97,4 @@ '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', | ||
'\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', | ||
'\xcC': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', | ||
'\xeC': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', | ||
'\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', | ||
'\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', | ||
'\xd1': 'N', '\xf1': 'n', | ||
@@ -107,3 +108,39 @@ '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', | ||
'\xde': 'Th', '\xfe': 'th', | ||
'\xdf': 'ss' | ||
'\xdf': 'ss', | ||
// Latin Extended-A block. | ||
'\u0100': 'A', '\u0102': 'A', '\u0104': 'A', | ||
'\u0101': 'a', '\u0103': 'a', '\u0105': 'a', | ||
'\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C', | ||
'\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c', | ||
'\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd', | ||
'\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E', | ||
'\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e', | ||
'\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G', | ||
'\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g', | ||
'\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h', | ||
'\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I', | ||
'\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i', | ||
'\u0134': 'J', '\u0135': 'j', | ||
'\u0136': 'K', '\u0137': 'k', '\u0138': 'k', | ||
'\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L', | ||
'\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l', | ||
'\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N', | ||
'\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n', | ||
'\u014c': 'O', '\u014e': 'O', '\u0150': 'O', | ||
'\u014d': 'o', '\u014f': 'o', '\u0151': 'o', | ||
'\u0154': 'R', '\u0156': 'R', '\u0158': 'R', | ||
'\u0155': 'r', '\u0157': 'r', '\u0159': 'r', | ||
'\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S', | ||
'\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's', | ||
'\u0162': 'T', '\u0164': 'T', '\u0166': 'T', | ||
'\u0163': 't', '\u0165': 't', '\u0167': 't', | ||
'\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U', | ||
'\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u', | ||
'\u0174': 'W', '\u0175': 'w', | ||
'\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y', | ||
'\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z', | ||
'\u017a': 'z', '\u017c': 'z', '\u017e': 'z', | ||
'\u0132': 'IJ', '\u0133': 'ij', | ||
'\u0152': 'Oe', '\u0153': 'oe', | ||
'\u0149': "'n", '\u017f': 'ss' | ||
}; | ||
@@ -146,2 +183,13 @@ | ||
/** | ||
* Splits an ASCII `string` into an array of its words. | ||
* | ||
* @private | ||
* @param {string} The string to inspect. | ||
* @returns {Array} Returns the words of `string`. | ||
*/ | ||
function asciiWords(string) { | ||
return string.match(reAsciiWord) || []; | ||
} | ||
/** | ||
* The base implementation of `_.propertyOf` without support for deep paths. | ||
@@ -160,3 +208,4 @@ * | ||
/** | ||
* Used by `_.deburr` to convert latin-1 supplementary letters to basic latin letters. | ||
* Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A | ||
* letters to basic Latin letters. | ||
* | ||
@@ -169,2 +218,24 @@ * @private | ||
/** | ||
* Checks if `string` contains a word composed of Unicode symbols. | ||
* | ||
* @private | ||
* @param {string} string The string to inspect. | ||
* @returns {boolean} Returns `true` if a word is found, else `false`. | ||
*/ | ||
function hasUnicodeWord(string) { | ||
return reHasUnicodeWord.test(string); | ||
} | ||
/** | ||
* Splits a Unicode `string` into an array of its words. | ||
* | ||
* @private | ||
* @param {string} The string to inspect. | ||
* @returns {Array} Returns the words of `string`. | ||
*/ | ||
function unicodeWords(string) { | ||
return string.match(reUnicodeWord) || []; | ||
} | ||
/** Used for built-in method references. */ | ||
@@ -175,3 +246,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. | ||
@@ -298,4 +369,5 @@ */ | ||
* Deburrs `string` by converting | ||
* [latin-1 supplementary letters](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) | ||
* to basic latin letters and removing | ||
* [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) | ||
* and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A) | ||
* letters to basic Latin letters and removing | ||
* [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). | ||
@@ -316,3 +388,3 @@ * | ||
string = toString(string); | ||
return string && string.replace(reLatin1, deburrLetter).replace(reComboMark, ''); | ||
return string && string.replace(reLatin, deburrLetter).replace(reComboMark, ''); | ||
} | ||
@@ -369,3 +441,3 @@ | ||
if (pattern === undefined) { | ||
pattern = reHasComplexWord.test(string) ? reComplexWord : reBasicWord; | ||
return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string); | ||
} | ||
@@ -372,0 +444,0 @@ return string.match(pattern) || []; |
{ | ||
"name": "lodash.snakecase", | ||
"version": "4.1.0", | ||
"version": "4.1.1", | ||
"description": "The lodash method `_.snakeCase` exported as a module.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://lodash.com/", |
@@ -1,2 +0,2 @@ | ||
# lodash.snakecase v4.1.0 | ||
# lodash.snakecase v4.1.1 | ||
@@ -18,2 +18,2 @@ The [lodash](https://lodash.com/) method `_.snakeCase` exported as a [Node.js](https://nodejs.org/) module. | ||
See the [documentation](https://lodash.com/docs#snakeCase) or [package source](https://github.com/lodash/lodash/blob/4.1.0-npm-packages/lodash.snakecase) for more details. | ||
See the [documentation](https://lodash.com/docs#snakeCase) or [package source](https://github.com/lodash/lodash/blob/4.1.1-npm-packages/lodash.snakecase) for more details. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
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
17725
399
0