From ce093845e11dce3cf5cb896f33e47985b294650b Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 14 Nov 2016 01:06:35 -0800 Subject: [PATCH] Ensure `_.pick` supports path arrays. [closes #2809] --- lodash.js | 2 +- test/test.js | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lodash.js b/lodash.js index 8b27a0483..93587fc5d 100644 --- a/lodash.js +++ b/lodash.js @@ -13529,7 +13529,7 @@ * // => { 'a': 1, 'c': 3 } */ var pick = flatRest(function(object, paths) { - return object == null ? {} : basePick(object, arrayMap(paths, toKey)); + return object == null ? {} : basePick(object, paths); }); /** diff --git a/test/test.js b/test/test.js index 50a0a6b93..e7753db2d 100644 --- a/test/test.js +++ b/test/test.js @@ -17597,6 +17597,15 @@ assert.deepEqual(_.pick(nested, 'b.c'), { 'b': { 'c': 2 } }); }); + QUnit.test('should support path arrays', function(assert) { + assert.expect(1); + + var object = { 'a.b.c': 1 }, + actual = _.pick(object, [['a.b.c']]); + + assert.deepEqual(actual, { 'a.b.c': 1 }); + }); + QUnit.test('should coerce property names to strings', function(assert) { assert.expect(1); @@ -23585,7 +23594,7 @@ }); }); - QUnit.test('should a new path array', function(assert) { + QUnit.test('should return new path array', function(assert) { assert.expect(1); assert.notStrictEqual(_.toPath('a.b.c'), _.toPath('a.b.c'));