mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 02:17:50 +00:00
Ensure _.slice handles a limit of 0 in Node 0.10.
This commit is contained in:
@@ -13553,18 +13553,21 @@
|
||||
* // => ['a', 'b']
|
||||
*/
|
||||
function split(string, separator, limit) {
|
||||
string = toString(string);
|
||||
if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
|
||||
separator = limit = undefined;
|
||||
}
|
||||
limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
|
||||
if (!limit) {
|
||||
return [];
|
||||
}
|
||||
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);
|
||||
return baseCastArray(stringToArray(string), 0, limit);
|
||||
}
|
||||
}
|
||||
return string.split(separator, limit);
|
||||
|
||||
Reference in New Issue
Block a user