mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-12 11:57:49 +00:00
Add isIterateeCall check to _.split.
This commit is contained in:
@@ -8505,8 +8505,8 @@
|
|||||||
* The guarded methods are:
|
* The guarded methods are:
|
||||||
* `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
|
* `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
|
||||||
* `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
|
* `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
|
||||||
* `sampleSize`, `slice`, `some`, `sortBy`, `take`, `takeRight`, `template`,
|
* `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
|
||||||
* `trim`, `trimEnd`, `trimStart`, and `words`
|
* `template`, `trim`, `trimEnd`, `trimStart`, and `words`
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
@@ -13561,6 +13561,9 @@
|
|||||||
*/
|
*/
|
||||||
function split(string, separator, limit) {
|
function split(string, separator, limit) {
|
||||||
string = toString(string);
|
string = toString(string);
|
||||||
|
if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
|
||||||
|
separator = limit = undefined;
|
||||||
|
}
|
||||||
if (string && (
|
if (string && (
|
||||||
typeof separator == 'string' ||
|
typeof separator == 'string' ||
|
||||||
(separator != null && !isRegExp(separator))
|
(separator != null && !isRegExp(separator))
|
||||||
|
|||||||
@@ -20115,6 +20115,15 @@
|
|||||||
assert.deepEqual(actual, expected);
|
assert.deepEqual(actual, expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QUnit.test('should work as an iteratee for methods like `_.map`', function(assert) {
|
||||||
|
assert.expect(1);
|
||||||
|
|
||||||
|
var strings = ['abc', 'def', 'ghi'],
|
||||||
|
actual = lodashStable.map(strings, _.split);
|
||||||
|
|
||||||
|
assert.deepEqual(actual, [['abc'], ['def'], ['ghi']]);
|
||||||
|
});
|
||||||
|
|
||||||
QUnit.test('should allow mixed string and array prototype methods', function(assert) {
|
QUnit.test('should allow mixed string and array prototype methods', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user