From bdac8974d8f43acb6ef6935a9092344ffc0b603d Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 3 May 2013 08:33:51 -0700 Subject: [PATCH] Realign `_.assign` and `_.defaults` with ES6 `Object.assign`. [closes #259] Former-commit-id: e8c89e4a130ed286ce07e1a2e848f50b182effae --- lodash.js | 1 + test/test.js | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/lodash.js b/lodash.js index a111b5c41..8e51b8255 100644 --- a/lodash.js +++ b/lodash.js @@ -585,6 +585,7 @@ 'while (++argsIndex < argsLength) {\n' + ' iterable = args[argsIndex];\n' + ' if (iterable && objectTypes[typeof iterable]) {', + 'arrays': false, 'loop': "if (typeof result[index] == 'undefined') result[index] = iterable[index]", 'bottom': ' }\n}' }; diff --git a/test/test.js b/test/test.js index 4ba65ce10..f260ca850 100644 --- a/test/test.js +++ b/test/test.js @@ -706,19 +706,21 @@ deepEqual(func({}, new Foo), {}); }); - test('lodash.' + methodName + ' should treat sparse arrays as dense', function() { - var array = Array(3); - array[0] = 1; - array[2] = 3; + if (methodName == 'merge') { + test('lodash.' + methodName + ' should treat sparse arrays as dense', function() { + var array = Array(3); + array[0] = 1; + array[2] = 3; - var actual = func([], array), - expected = array.slice(); + var actual = func([], array), + expected = array.slice(); - expected[1] = undefined; + expected[1] = undefined; - ok(1 in actual); - deepEqual(actual, expected); - }); + ok(1 in actual); + deepEqual(actual, expected); + }); + } }); /*--------------------------------------------------------------------------*/