From 0aa8ad202aaa91c32720e5e274ca30d12d642d8d Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 22 Aug 2015 18:41:48 -0700 Subject: [PATCH] Implement `copyObject` by way of `copyObjectWith`. --- lodash.js | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/lodash.js b/lodash.js index 2d6fd1c95..c519218ac 100644 --- a/lodash.js +++ b/lodash.js @@ -2949,16 +2949,7 @@ * @returns {Object} Returns `object`. */ function copyObject(source, props, object) { - object || (object = {}); - - var index = -1, - length = props.length; - - while (++index < length) { - var key = props[index]; - assignValue(object, key, source[key], object[key]); - } - return object; + return copyObjectWith(source, props, object); } /** @@ -2968,11 +2959,11 @@ * @private * @param {Object} source The object to copy properties from. * @param {Array} props The property names to copy. - * @param {Function} [customizer] The function to customize copied values. * @param {Object} [object={}] The object to copy properties to. + * @param {Function} [customizer] The function to customize copied values. * @returns {Object} Returns `object`. */ - function copyObjectWith(source, props, customizer, object) { + function copyObjectWith(source, props, object, customizer) { object || (object = {}); var index = -1, @@ -8604,7 +8595,7 @@ * // => { 'user': 'barney', 'age': 36 } */ var assignWith = createAssigner(function(object, source, customizer) { - copyObjectWith(source, keys(source), customizer, object); + copyObjectWith(source, keys(source), object, customizer); }); /** @@ -8755,7 +8746,7 @@ * // => { 'user': 'barney', 'age': 36 } */ var extendWith = createAssigner(function(object, source, customizer) { - copyObjectWith(source, keysIn(source), customizer, object); + copyObjectWith(source, keysIn(source), object, customizer); }); /**