1 | var baseToString = require('./_baseToString'),
|
2 | castSlice = require('./_castSlice'),
|
3 | hasUnicode = require('./_hasUnicode'),
|
4 | isIterateeCall = require('./_isIterateeCall'),
|
5 | isRegExp = require('./isRegExp'),
|
6 | stringToArray = require('./_stringToArray'),
|
7 | toString = require('./toString');
|
8 |
|
9 |
|
10 | var MAX_ARRAY_LENGTH = 4294967295;
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | function split(string, separator, limit) {
|
32 | if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
|
33 | separator = limit = undefined;
|
34 | }
|
35 | limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
|
36 | if (!limit) {
|
37 | return [];
|
38 | }
|
39 | string = toString(string);
|
40 | if (string && (
|
41 | typeof separator == 'string' ||
|
42 | (separator != null && !isRegExp(separator))
|
43 | )) {
|
44 | separator = baseToString(separator);
|
45 | if (!separator && hasUnicode(string)) {
|
46 | return castSlice(stringToArray(string), 0, limit);
|
47 | }
|
48 | }
|
49 | return string.split(separator, limit);
|
50 | }
|
51 |
|
52 | module.exports = split;
|