mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 02:47:50 +00:00
Update reWords detection.
This commit is contained in:
52
lodash.js
52
lodash.js
@@ -143,29 +143,47 @@
|
|||||||
/** Used to match unescaped characters in compiled string literals. */
|
/** Used to match unescaped characters in compiled string literals. */
|
||||||
var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
|
var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
|
||||||
|
|
||||||
/** Used to compose unicode related regexes. */
|
/** Used to compose unicode character classes. */
|
||||||
var rsAstralRange = '\\ud800-\\udfff',
|
var rsAstralRange = '\\ud800-\\udfff',
|
||||||
rsAstral = '[' + rsAstralRange + ']',
|
|
||||||
rsComboRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
|
rsComboRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
|
||||||
|
rsDingbatRange = '\\u2700-\\u27bf',
|
||||||
|
rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
|
||||||
|
rsMathOpRange = '\\xd7\\xf7',
|
||||||
|
rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
|
||||||
|
rsQuoteRange = '\\u2018\\u2019\\u201c\\u201d',
|
||||||
|
rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000',
|
||||||
|
rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
|
||||||
|
rsVarRange = '\\ufe0e\\ufe0f',
|
||||||
|
rsBreakRange = rsMathOpRange + rsNonCharRange + rsQuoteRange + rsSpaceRange;
|
||||||
|
|
||||||
|
/** Used to compose unicode capture groups. */
|
||||||
|
var rsAstral = '[' + rsAstralRange + ']',
|
||||||
|
rsBreak = '[' + rsBreakRange + ']',
|
||||||
rsCombo = '[' + rsComboRange + ']',
|
rsCombo = '[' + rsComboRange + ']',
|
||||||
rsDigits = '\\d+',
|
rsDigits = '\\d+',
|
||||||
rsDingbat = '[\\u2700-\\u27bf]',
|
rsDingbat = '[' + rsDingbatRange + ']',
|
||||||
rsLowers = '[a-z\\xdf-\\xf6\\xf8-\\xff]+',
|
rsLower = '[' + rsLowerRange + ']',
|
||||||
|
rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
|
||||||
rsModifier = '(?:\\ud83c[\\udffb-\\udfff])',
|
rsModifier = '(?:\\ud83c[\\udffb-\\udfff])',
|
||||||
rsNonAstral = '[^' + rsAstralRange + ']',
|
rsNonAstral = '[^' + rsAstralRange + ']',
|
||||||
rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
|
rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
|
||||||
|
rsSpace = '[' + rsSpaceRange + ']',
|
||||||
rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
|
rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
|
||||||
rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?' , rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')',
|
rsUpper = '[' + rsUpperRange + ']',
|
||||||
rsUpper = '[A-Z\\xc0-\\xd6\\xd8-\\xde]',
|
rsZWJ = '\\u200d';
|
||||||
rsVS = '\\ufe0e\\ufe0f',
|
|
||||||
rsZWJ = '\\u200d',
|
/** Used to compose unicode regexes. */
|
||||||
|
var rsLowerMisc = '(?:' + rsLower + '|' + rsMisc + ')',
|
||||||
|
rsUpperMisc = '(?:' + rsUpper + '|' + rsMisc + ')',
|
||||||
reOptMod = rsModifier + '?',
|
reOptMod = rsModifier + '?',
|
||||||
rsOptVS = '[' + rsVS + ']?',
|
rsOptVar = '[' + rsVarRange + ']?',
|
||||||
rsJoiner = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVS + reOptMod + ')*',
|
rsJoiner = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
|
||||||
rsSeq = rsOptVS + reOptMod + rsJoiner;
|
rsSeq = rsOptVar + reOptMod + rsJoiner,
|
||||||
|
rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
|
||||||
|
rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
|
||||||
|
|
||||||
/** Used to match [zero-width joiners and code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
|
/** Used to match [zero-width joiners and code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
|
||||||
var reAdvSymbol = RegExp('[' + rsZWJ + rsVS + rsAstralRange + rsComboRange + ']');
|
var reAdvSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
|
||||||
|
|
||||||
/** Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). */
|
/** Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). */
|
||||||
var reComboMark = RegExp(rsCombo, 'g');
|
var reComboMark = RegExp(rsCombo, 'g');
|
||||||
@@ -175,11 +193,11 @@
|
|||||||
|
|
||||||
/** Used to match words to create compound words. */
|
/** Used to match words to create compound words. */
|
||||||
var reWord = RegExp([
|
var reWord = RegExp([
|
||||||
rsUpper + '+(?=' + rsUpper + rsLowers + ')',
|
rsUpper + '?' + rsLower + '+(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
|
||||||
rsUpper + '?' + rsLowers,
|
rsUpperMisc + '+(?=' + [rsBreak, rsUpper + rsLowerMisc, '$'].join('|') + ')',
|
||||||
rsUpper + '+',
|
rsUpper + '?' + rsLowerMisc + '+',
|
||||||
'(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
|
rsDigits + '(?:' + rsLowerMisc + '+)?',
|
||||||
rsDigits
|
rsEmoji
|
||||||
].join('|'), 'g');
|
].join('|'), 'g');
|
||||||
|
|
||||||
/** Used to assign default `context` object properties. */
|
/** Used to assign default `context` object properties. */
|
||||||
|
|||||||
@@ -1832,7 +1832,7 @@
|
|||||||
return func(result);
|
return func(result);
|
||||||
}, 'enable 24h format');
|
}, 'enable 24h format');
|
||||||
|
|
||||||
assert.strictEqual(actual, 'enable24HFormat');
|
assert.strictEqual(actual, 'enable24hFormat');
|
||||||
});
|
});
|
||||||
}());
|
}());
|
||||||
|
|
||||||
@@ -1844,7 +1844,7 @@
|
|||||||
QUnit.test('should work with numbers', function(assert) {
|
QUnit.test('should work with numbers', function(assert) {
|
||||||
assert.expect(4);
|
assert.expect(4);
|
||||||
|
|
||||||
assert.strictEqual(_.camelCase('enable 24h format'), 'enable24HFormat');
|
assert.strictEqual(_.camelCase('enable 24h format'), 'enable24hFormat');
|
||||||
assert.strictEqual(_.camelCase('too legit 2 quit'), 'tooLegit2Quit');
|
assert.strictEqual(_.camelCase('too legit 2 quit'), 'tooLegit2Quit');
|
||||||
assert.strictEqual(_.camelCase('walk 500 miles'), 'walk500Miles');
|
assert.strictEqual(_.camelCase('walk 500 miles'), 'walk500Miles');
|
||||||
assert.strictEqual(_.camelCase('xhr2 request'), 'xhr2Request');
|
assert.strictEqual(_.camelCase('xhr2 request'), 'xhr2Request');
|
||||||
@@ -19197,7 +19197,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
var expected = _.map(values, function(value) {
|
var expected = _.map(values, function(value) {
|
||||||
return [1, [value], ['o']];
|
return [1, [value], [value]];
|
||||||
});
|
});
|
||||||
|
|
||||||
var actual = _.map(values, function(value) {
|
var actual = _.map(values, function(value) {
|
||||||
@@ -19770,7 +19770,7 @@
|
|||||||
assert.expect(6);
|
assert.expect(6);
|
||||||
|
|
||||||
assert.deepEqual(_.words('aeiouAreVowels'), ['aeiou', 'Are', 'Vowels']);
|
assert.deepEqual(_.words('aeiouAreVowels'), ['aeiou', 'Are', 'Vowels']);
|
||||||
assert.deepEqual(_.words('enable 24h format'), ['enable', '24', 'h', 'format']);
|
assert.deepEqual(_.words('enable 24h format'), ['enable', '24h', 'format']);
|
||||||
assert.deepEqual(_.words('LETTERSAeiouAreVowels'), ['LETTERS', 'Aeiou', 'Are', 'Vowels']);
|
assert.deepEqual(_.words('LETTERSAeiouAreVowels'), ['LETTERS', 'Aeiou', 'Are', 'Vowels']);
|
||||||
assert.deepEqual(_.words('tooLegit2Quit'), ['too', 'Legit', '2', 'Quit']);
|
assert.deepEqual(_.words('tooLegit2Quit'), ['too', 'Legit', '2', 'Quit']);
|
||||||
assert.deepEqual(_.words('walk500Miles'), ['walk', '500', 'Miles']);
|
assert.deepEqual(_.words('walk500Miles'), ['walk', '500', 'Miles']);
|
||||||
|
|||||||
Reference in New Issue
Block a user