Bump to v4.9.0.

This commit is contained in:
John-David Dalton
2016-04-07 21:35:23 -07:00
parent 8349627be6
commit 57f1942947
48 changed files with 257 additions and 155 deletions

View File

@@ -1,4 +1,19 @@
define(['./toString'], function(toString) {
define(['./isRegExp', './_stringToArray', './toString'], function(isRegExp, stringToArray, toString) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff',
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
rsComboSymbolsRange = '\\u20d0-\\u20f0',
rsVarRange = '\\ufe0e\\ufe0f';
/** Used to compose unicode capture groups. */
var rsZWJ = '\\u200d';
/** 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 + ']');
/**
* Splits `string` by `separator`.
@@ -20,7 +35,18 @@ define(['./toString'], function(toString) {
* // => ['a', 'b']
*/
function split(string, separator, limit) {
return toString(string).split(separator, limit);
string = toString(string);
if (string && (
typeof separator == 'string' ||
(separator != null && !isRegExp(separator))
)) {
separator += '';
if (separator == '' && reHasComplexSymbol.test(string)) {
var strSymbols = stringToArray(string);
return limit === undefined ? strSymbols : strSymbols.slice(0, limit < 0 ? 0 : limit);
}
}
return string.split(separator, limit);
}
return split;