Bump to v4.9.0.

This commit is contained in:
John-David Dalton
2016-04-07 21:49:55 -07:00
parent 7c17af79c7
commit 7d39d58e43
53 changed files with 428 additions and 317 deletions

View File

@@ -1,4 +1,18 @@
var toString = require('./toString');
var isRegExp = require('./isRegExp'),
stringToArray = require('./_stringToArray'),
toString = require('./toString');
/** 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 +34,18 @@ var toString = require('./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);
}
module.exports = split;