From c1958daf65e22da9b12134d9995502ab2718d32c Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 8 Apr 2016 08:48:29 -0700 Subject: [PATCH] Update handling of `limit` to the current es6 draft. --- lodash.js | 2 +- test/test.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lodash.js b/lodash.js index 9e8012824..0fc7aae7f 100644 --- a/lodash.js +++ b/lodash.js @@ -13568,7 +13568,7 @@ separator += ''; if (separator == '' && reHasComplexSymbol.test(string)) { var strSymbols = stringToArray(string); - return limit === undefined ? strSymbols : strSymbols.slice(0, limit < 0 ? 0 : limit); + return limit === undefined ? strSymbols : strSymbols.slice(0, limit >>> 0); } } return string.split(separator, limit); diff --git a/test/test.js b/test/test.js index 5306ddf7a..378c715e1 100644 --- a/test/test.js +++ b/test/test.js @@ -23251,7 +23251,7 @@ thumbsUp = '\ud83d\udc4d'; QUnit.test('should account for astral symbols', function(assert) { - assert.expect(32); + assert.expect(33); var allHearts = _.repeat(hearts, 10), chars = hearts + comboGlyph, @@ -23274,7 +23274,8 @@ assert.strictEqual(_.size(string), 13); assert.deepEqual(_.split(string, ' '), ['A', leafs + ',', comboGlyph + ',', 'and', rocket]); assert.deepEqual(_.split(string, ' ', 3), ['A', leafs + ',', comboGlyph + ',']); - assert.deepEqual(_.split(string, undefined), string.split(undefined)); + assert.deepEqual(_.split(string, undefined), [string]); + assert.deepEqual(_.split(string, undefined, -1), [string]); assert.deepEqual(_.split(string, undefined, 0), string.split(undefined, 0)); var expected = ['A', ' ', leafs, ',', ' ', comboGlyph, ',', ' ', 'a', 'n', 'd', ' ', rocket];