diff --git a/README.md b/README.md index 8af04b4fe..38088be4a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# lodash-es v4.5.0 +# lodash-es v4.5.1 The [lodash](https://lodash.com/) library exported as [ES](http://www.ecma-international.org/ecma-262/6.0/) modules. @@ -7,4 +7,4 @@ Generated using [lodash-cli](https://www.npmjs.com/package/lodash-cli): $ lodash modularize exports=es -o ./ ``` -See the [package source](https://github.com/lodash/lodash/tree/4.5.0-es) for more details. +See the [package source](https://github.com/lodash/lodash/tree/4.5.1-es) for more details. diff --git a/_assignValue.js b/_assignValue.js index 59257f10b..b6c54e896 100644 --- a/_assignValue.js +++ b/_assignValue.js @@ -18,8 +18,7 @@ var hasOwnProperty = objectProto.hasOwnProperty; */ function assignValue(object, key, value) { var objValue = object[key]; - if ((!eq(objValue, value) || - (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) || + if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || (value === undefined && !(key in object))) { object[key] = value; } diff --git a/_composeArgs.js b/_composeArgs.js index 854f489aa..21f7e43de 100644 --- a/_composeArgs.js +++ b/_composeArgs.js @@ -9,23 +9,28 @@ var nativeMax = Math.max; * @param {Array|Object} args The provided arguments. * @param {Array} partials The arguments to prepend to those provided. * @param {Array} holders The `partials` placeholder indexes. + * @params {boolean} [isCurried] Specify composing for a curried function. * @returns {Array} Returns the new array of composed arguments. */ -function composeArgs(args, partials, holders) { - var holdersLength = holders.length, - argsIndex = -1, - argsLength = nativeMax(args.length - holdersLength, 0), +function composeArgs(args, partials, holders, isCurried) { + var argsIndex = -1, + argsLength = args.length, + holdersLength = holders.length, leftIndex = -1, leftLength = partials.length, - result = Array(leftLength + argsLength); + rangeLength = nativeMax(argsLength - holdersLength, 0), + result = Array(leftLength + rangeLength), + isUncurried = !isCurried; while (++leftIndex < leftLength) { result[leftIndex] = partials[leftIndex]; } while (++argsIndex < holdersLength) { - result[holders[argsIndex]] = args[argsIndex]; + if (isUncurried || argsIndex < argsLength) { + result[holders[argsIndex]] = args[argsIndex]; + } } - while (argsLength--) { + while (rangeLength--) { result[leftIndex++] = args[argsIndex++]; } return result; diff --git a/_composeArgsRight.js b/_composeArgsRight.js index 48b059c8c..65db64190 100644 --- a/_composeArgsRight.js +++ b/_composeArgsRight.js @@ -9,18 +9,21 @@ var nativeMax = Math.max; * @param {Array|Object} args The provided arguments. * @param {Array} partials The arguments to append to those provided. * @param {Array} holders The `partials` placeholder indexes. + * @params {boolean} [isCurried] Specify composing for a curried function. * @returns {Array} Returns the new array of composed arguments. */ -function composeArgsRight(args, partials, holders) { - var holdersIndex = -1, +function composeArgsRight(args, partials, holders, isCurried) { + var argsIndex = -1, + argsLength = args.length, + holdersIndex = -1, holdersLength = holders.length, - argsIndex = -1, - argsLength = nativeMax(args.length - holdersLength, 0), rightIndex = -1, rightLength = partials.length, - result = Array(argsLength + rightLength); + rangeLength = nativeMax(argsLength - holdersLength, 0), + result = Array(rangeLength + rightLength), + isUncurried = !isCurried; - while (++argsIndex < argsLength) { + while (++argsIndex < rangeLength) { result[argsIndex] = args[argsIndex]; } var offset = argsIndex; @@ -28,7 +31,9 @@ function composeArgsRight(args, partials, holders) { result[offset + rightIndex] = partials[rightIndex]; } while (++holdersIndex < holdersLength) { - result[offset + holders[holdersIndex]] = args[argsIndex++]; + if (isUncurried || argsIndex < argsLength) { + result[offset + holders[holdersIndex]] = args[argsIndex++]; + } } return result; } diff --git a/_countHolders.js b/_countHolders.js new file mode 100644 index 000000000..c4b76fb7b --- /dev/null +++ b/_countHolders.js @@ -0,0 +1,21 @@ +/** + * Gets the number of `placeholder` occurrences in `array`. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} placeholder The placeholder to search for. + * @returns {number} Returns the placeholder count. + */ +function countHolders(array, placeholder) { + var length = array.length, + result = 0; + + while (length--) { + if (array[length] === placeholder) { + result++; + } + } + return result; +} + +export default countHolders; diff --git a/_createCurryWrapper.js b/_createCurryWrapper.js index 4b396c6b7..8d727c88a 100644 --- a/_createCurryWrapper.js +++ b/_createCurryWrapper.js @@ -2,6 +2,7 @@ import apply from './_apply'; import createCtorWrapper from './_createCtorWrapper'; import createHybridWrapper from './_createHybridWrapper'; import createRecurryWrapper from './_createRecurryWrapper'; +import getPlaceholder from './_getPlaceholder'; import replaceHolders from './_replaceHolders'; import root from './_root'; @@ -19,10 +20,9 @@ function createCurryWrapper(func, bitmask, arity) { function wrapper() { var length = arguments.length, - index = length, args = Array(length), - fn = (this && this !== root && this instanceof wrapper) ? Ctor : func, - placeholder = wrapper.placeholder; + index = length, + placeholder = getPlaceholder(wrapper); while (index--) { args[index] = arguments[index]; @@ -32,9 +32,13 @@ function createCurryWrapper(func, bitmask, arity) { : replaceHolders(args, placeholder); length -= holders.length; - return length < arity - ? createRecurryWrapper(func, bitmask, createHybridWrapper, placeholder, undefined, args, holders, undefined, undefined, arity - length) - : apply(fn, this, args); + if (length < arity) { + return createRecurryWrapper( + func, bitmask, createHybridWrapper, wrapper.placeholder, undefined, + args, holders, undefined, undefined, arity - length); + } + var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; + return apply(fn, this, args); } return wrapper; } diff --git a/_createHybridWrapper.js b/_createHybridWrapper.js index c88c8e6c4..8fdab8b72 100644 --- a/_createHybridWrapper.js +++ b/_createHybridWrapper.js @@ -1,7 +1,9 @@ import composeArgs from './_composeArgs'; import composeArgsRight from './_composeArgsRight'; +import countHolders from './_countHolders'; import createCtorWrapper from './_createCtorWrapper'; import createRecurryWrapper from './_createRecurryWrapper'; +import getPlaceholder from './_getPlaceholder'; import reorder from './_reorder'; import replaceHolders from './_replaceHolders'; import root from './_root'; @@ -35,8 +37,7 @@ function createHybridWrapper(func, bitmask, thisArg, partials, holders, partials var isAry = bitmask & ARY_FLAG, isBind = bitmask & BIND_FLAG, isBindKey = bitmask & BIND_KEY_FLAG, - isCurry = bitmask & CURRY_FLAG, - isCurryRight = bitmask & CURRY_RIGHT_FLAG, + isCurried = bitmask & (CURRY_FLAG | CURRY_RIGHT_FLAG), isFlip = bitmask & FLIP_FLAG, Ctor = isBindKey ? undefined : createCtorWrapper(func); @@ -48,33 +49,34 @@ function createHybridWrapper(func, bitmask, thisArg, partials, holders, partials while (index--) { args[index] = arguments[index]; } + if (isCurried) { + var placeholder = getPlaceholder(wrapper), + holdersCount = countHolders(args, placeholder); + } if (partials) { - args = composeArgs(args, partials, holders); + args = composeArgs(args, partials, holders, isCurried); } if (partialsRight) { - args = composeArgsRight(args, partialsRight, holdersRight); + args = composeArgsRight(args, partialsRight, holdersRight, isCurried); } - if (isCurry || isCurryRight) { - var placeholder = wrapper.placeholder, - argsHolders = replaceHolders(args, placeholder); - - length -= argsHolders.length; - if (length < arity) { - return createRecurryWrapper( - func, bitmask, createHybridWrapper, placeholder, thisArg, args, - argsHolders, argPos, ary, arity - length - ); - } + length -= holdersCount; + if (isCurried && length < arity) { + var newHolders = replaceHolders(args, placeholder); + return createRecurryWrapper( + func, bitmask, createHybridWrapper, wrapper.placeholder, thisArg, + args, newHolders, argPos, ary, arity - length + ); } var thisBinding = isBind ? thisArg : this, fn = isBindKey ? thisBinding[func] : func; + length = args.length; if (argPos) { args = reorder(args, argPos); - } else if (isFlip && args.length > 1) { + } else if (isFlip && length > 1) { args.reverse(); } - if (isAry && ary < args.length) { + if (isAry && ary < length) { args.length = ary; } if (this && this !== root && this instanceof wrapper) { diff --git a/_createRecurryWrapper.js b/_createRecurryWrapper.js index 73e3b078d..a2add3dbb 100644 --- a/_createRecurryWrapper.js +++ b/_createRecurryWrapper.js @@ -17,7 +17,7 @@ var BIND_FLAG = 1, * @param {Function} func The function to wrap. * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details. * @param {Function} wrapFunc The function to create the `func` wrapper. - * @param {*} placeholder The placeholder to replace. + * @param {*} placeholder The placeholder value. * @param {*} [thisArg] The `this` binding of `func`. * @param {Array} [partials] The arguments to prepend to those provided to the new function. * @param {Array} [holders] The `partials` placeholder indexes. @@ -29,7 +29,7 @@ var BIND_FLAG = 1, function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) { var isCurry = bitmask & CURRY_FLAG, newArgPos = argPos ? copyArray(argPos) : undefined, - newsHolders = isCurry ? holders : undefined, + newHolders = isCurry ? holders : undefined, newHoldersRight = isCurry ? undefined : holders, newPartials = isCurry ? partials : undefined, newPartialsRight = isCurry ? undefined : partials; @@ -41,7 +41,7 @@ function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, par bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG); } var newData = [ - func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, + func, bitmask, thisArg, newPartials, newHolders, newPartialsRight, newHoldersRight, newArgPos, ary, arity ]; diff --git a/_getPlaceholder.js b/_getPlaceholder.js new file mode 100644 index 000000000..ba0d7543b --- /dev/null +++ b/_getPlaceholder.js @@ -0,0 +1,13 @@ +/** + * Gets the argument placeholder value for `func`. + * + * @private + * @param {Function} func The function to inspect. + * @returns {*} Returns the placeholder value. + */ +function getPlaceholder(func) { + var object = func; + return object.placeholder; +} + +export default getPlaceholder; diff --git a/_initCloneObject.js b/_initCloneObject.js index 41d926509..b6c8dd58c 100644 --- a/_initCloneObject.js +++ b/_initCloneObject.js @@ -2,6 +2,9 @@ import baseCreate from './_baseCreate'; import isFunction from './isFunction'; import isPrototype from './_isPrototype'; +/** Built-in value references. */ +var getPrototypeOf = Object.getPrototypeOf; + /** * Initializes an object clone. * @@ -10,11 +13,9 @@ import isPrototype from './_isPrototype'; * @returns {Object} Returns the initialized clone. */ function initCloneObject(object) { - if (isPrototype(object)) { - return {}; - } - var Ctor = object.constructor; - return baseCreate(isFunction(Ctor) ? Ctor.prototype : undefined); + return (isFunction(object.constructor) && !isPrototype(object)) + ? baseCreate(getPrototypeOf(object)) + : {}; } export default initCloneObject; diff --git a/_isPrototype.js b/_isPrototype.js index f6c7660d0..9214b1c4d 100644 --- a/_isPrototype.js +++ b/_isPrototype.js @@ -1,3 +1,5 @@ +import isFunction from './isFunction'; + /** Used for built-in method references. */ var objectProto = Object.prototype; @@ -10,7 +12,7 @@ var objectProto = Object.prototype; */ function isPrototype(value) { var Ctor = value && value.constructor, - proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; + proto = (isFunction(Ctor) && Ctor.prototype) || objectProto; return value === proto; } diff --git a/_mergeData.js b/_mergeData.js index 3691b8ce5..aef1c8077 100644 --- a/_mergeData.js +++ b/_mergeData.js @@ -39,9 +39,9 @@ function mergeData(data, source) { isCommon = newBitmask < (BIND_FLAG | BIND_KEY_FLAG | ARY_FLAG); var isCombo = - (srcBitmask == ARY_FLAG && (bitmask == CURRY_FLAG)) || - (srcBitmask == ARY_FLAG && (bitmask == REARG_FLAG) && (data[7].length <= source[8])) || - (srcBitmask == (ARY_FLAG | REARG_FLAG) && (source[7].length <= source[8]) && (bitmask == CURRY_FLAG)); + ((srcBitmask == ARY_FLAG) && (bitmask == CURRY_FLAG)) || + ((srcBitmask == ARY_FLAG) && (bitmask == REARG_FLAG) && (data[7].length <= source[8])) || + ((srcBitmask == (ARY_FLAG | REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == CURRY_FLAG)); // Exit early if metadata can't be merged. if (!(isCommon || isCombo)) { @@ -51,7 +51,7 @@ function mergeData(data, source) { if (srcBitmask & BIND_FLAG) { data[2] = source[2]; // Set when currying a bound function. - newBitmask |= (bitmask & BIND_FLAG) ? 0 : CURRY_BOUND_FLAG; + newBitmask |= bitmask & BIND_FLAG ? 0 : CURRY_BOUND_FLAG; } // Compose partial arguments. var value = source[3]; diff --git a/_replaceHolders.js b/_replaceHolders.js index 274726863..7a2e62e78 100644 --- a/_replaceHolders.js +++ b/_replaceHolders.js @@ -17,7 +17,8 @@ function replaceHolders(array, placeholder) { result = []; while (++index < length) { - if (array[index] === placeholder) { + var value = array[index]; + if (value === placeholder || value === PLACEHOLDER) { array[index] = PLACEHOLDER; result[++resIndex] = index; } diff --git a/bind.js b/bind.js index 350ff3d54..2cc4fc5c2 100644 --- a/bind.js +++ b/bind.js @@ -1,4 +1,5 @@ import createWrapper from './_createWrapper'; +import getPlaceholder from './_getPlaceholder'; import replaceHolders from './_replaceHolders'; import rest from './rest'; @@ -44,9 +45,7 @@ var BIND_FLAG = 1, var bind = rest(function(func, thisArg, partials) { var bitmask = BIND_FLAG; if (partials.length) { - var placeholder = bind.placeholder, - holders = replaceHolders(partials, placeholder); - + var holders = replaceHolders(partials, getPlaceholder(bind)); bitmask |= PARTIAL_FLAG; } return createWrapper(func, bitmask, thisArg, partials, holders); diff --git a/bindKey.js b/bindKey.js index c0bfd695c..882b86b6f 100644 --- a/bindKey.js +++ b/bindKey.js @@ -1,4 +1,5 @@ import createWrapper from './_createWrapper'; +import getPlaceholder from './_getPlaceholder'; import replaceHolders from './_replaceHolders'; import rest from './rest'; @@ -54,9 +55,7 @@ var BIND_FLAG = 1, var bindKey = rest(function(object, key, partials) { var bitmask = BIND_FLAG | BIND_KEY_FLAG; if (partials.length) { - var placeholder = bindKey.placeholder, - holders = replaceHolders(partials, placeholder); - + var holders = replaceHolders(partials, getPlaceholder(bindKey)); bitmask |= PARTIAL_FLAG; } return createWrapper(key, bitmask, object, partials, holders); diff --git a/isError.js b/isError.js index 01565170c..a1e2d82b9 100644 --- a/isError.js +++ b/isError.js @@ -33,9 +33,8 @@ function isError(value) { if (!isObjectLike(value)) { return false; } - var Ctor = value.constructor; return (objectToString.call(value) == errorTag) || - (typeof Ctor == 'function' && objectToString.call(Ctor.prototype) == errorTag); + (typeof value.message == 'string' && typeof value.name == 'string'); } export default isError; diff --git a/isPlainObject.js b/isPlainObject.js index 8e11c789e..1b375b87e 100644 --- a/isPlainObject.js +++ b/isPlainObject.js @@ -54,10 +54,7 @@ function isPlainObject(value) { objectToString.call(value) != objectTag || isHostObject(value)) { return false; } - var proto = objectProto; - if (typeof value.constructor == 'function') { - proto = getPrototypeOf(value); - } + var proto = getPrototypeOf(value); if (proto === null) { return true; } diff --git a/lodash.default.js b/lodash.default.js index 91e7bb0aa..d8b4684a6 100644 --- a/lodash.default.js +++ b/lodash.default.js @@ -1,6 +1,6 @@ /** * @license - * lodash 4.5.0 (Custom Build) + * lodash 4.5.1 (Custom Build) * Build: `lodash modularize exports="es" -o ./` * Copyright 2012-2016 The Dojo Foundation * Based on Underscore.js 1.8.3 @@ -44,7 +44,7 @@ import toInteger from './toInteger'; import lodash from './wrapperLodash'; /** Used as the semantic version number. */ -var VERSION = '4.5.0'; +var VERSION = '4.5.1'; /** Used to compose bitmasks for wrapper metadata. */ var BIND_KEY_FLAG = 2; diff --git a/lodash.js b/lodash.js index 4cd73ed0d..b493d24cf 100644 --- a/lodash.js +++ b/lodash.js @@ -1,6 +1,6 @@ /** * @license - * lodash 4.5.0 (Custom Build) + * lodash 4.5.1 (Custom Build) * Build: `lodash modularize exports="es" -o ./` * Copyright 2012-2016 The Dojo Foundation * Based on Underscore.js 1.8.3 diff --git a/mapKeys.js b/mapKeys.js index c0b7e3b86..9ae244ac8 100644 --- a/mapKeys.js +++ b/mapKeys.js @@ -4,7 +4,8 @@ import baseIteratee from './_baseIteratee'; /** * The opposite of `_.mapValues`; this method creates an object with the * same values as `object` and keys generated by running each own enumerable - * property of `object` through `iteratee`. + * property of `object` through `iteratee`. The iteratee is invoked with + * three arguments: (value, key, object). * * @static * @memberOf _ diff --git a/mapValues.js b/mapValues.js index 86b6957d5..c7ad0bf47 100644 --- a/mapValues.js +++ b/mapValues.js @@ -4,7 +4,7 @@ import baseIteratee from './_baseIteratee'; /** * Creates an object with the same keys as `object` and values generated by * running each own enumerable property of `object` through `iteratee`. The - * iteratee function is invoked with three arguments: (value, key, object). + * iteratee is invoked with three arguments: (value, key, object). * * @static * @memberOf _ diff --git a/omitBy.js b/omitBy.js index f61c3dabd..8ee1a4696 100644 --- a/omitBy.js +++ b/omitBy.js @@ -2,9 +2,10 @@ import baseIteratee from './_baseIteratee'; import basePickBy from './_basePickBy'; /** - * The opposite of `_.pickBy`; this method creates an object composed of the - * own and inherited enumerable properties of `object` that `predicate` - * doesn't return truthy for. + * The opposite of `_.pickBy`; this method creates an object composed of + * the own and inherited enumerable properties of `object` that `predicate` + * doesn't return truthy for. The predicate is invoked with two arguments: + * (value, key). * * @static * @memberOf _ @@ -20,7 +21,7 @@ import basePickBy from './_basePickBy'; * // => { 'b': '2' } */ function omitBy(object, predicate) { - predicate = baseIteratee(predicate, 2); + predicate = baseIteratee(predicate); return basePickBy(object, function(value, key) { return !predicate(value, key); }); diff --git a/package.json b/package.json index e8af30c25..59f926e0f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lodash-es", - "version": "4.5.0", + "version": "4.5.1", "description": "Lodash exported as ES modules.", "homepage": "https://lodash.com/custom-builds", "license": "MIT", diff --git a/partial.js b/partial.js index 1fcbf12b5..520c468f9 100644 --- a/partial.js +++ b/partial.js @@ -1,4 +1,5 @@ import createWrapper from './_createWrapper'; +import getPlaceholder from './_getPlaceholder'; import replaceHolders from './_replaceHolders'; import rest from './rest'; @@ -38,9 +39,7 @@ var PARTIAL_FLAG = 32; * // => 'hi fred' */ var partial = rest(function(func, partials) { - var placeholder = partial.placeholder, - holders = replaceHolders(partials, placeholder); - + var holders = replaceHolders(partials, getPlaceholder(partial)); return createWrapper(func, PARTIAL_FLAG, undefined, partials, holders); }); diff --git a/partialRight.js b/partialRight.js index d1c0b1295..8607955a1 100644 --- a/partialRight.js +++ b/partialRight.js @@ -1,4 +1,5 @@ import createWrapper from './_createWrapper'; +import getPlaceholder from './_getPlaceholder'; import replaceHolders from './_replaceHolders'; import rest from './rest'; @@ -37,9 +38,7 @@ var PARTIAL_RIGHT_FLAG = 64; * // => 'hello fred' */ var partialRight = rest(function(func, partials) { - var placeholder = partialRight.placeholder, - holders = replaceHolders(partials, placeholder); - + var holders = replaceHolders(partials, getPlaceholder(partialRight)); return createWrapper(func, PARTIAL_RIGHT_FLAG, undefined, partials, holders); }); diff --git a/pickBy.js b/pickBy.js index 109dd4115..3412a1928 100644 --- a/pickBy.js +++ b/pickBy.js @@ -19,7 +19,7 @@ import basePickBy from './_basePickBy'; * // => { 'a': 1, 'c': 3 } */ function pickBy(object, predicate) { - return object == null ? {} : basePickBy(object, baseIteratee(predicate, 2)); + return object == null ? {} : basePickBy(object, baseIteratee(predicate)); } export default pickBy; diff --git a/pull.js b/pull.js index d8adc2b88..07b996488 100644 --- a/pull.js +++ b/pull.js @@ -6,7 +6,8 @@ import rest from './rest'; * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) * for equality comparisons. * - * **Note:** Unlike `_.without`, this method mutates `array`. + * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove` + * to remove elements from an array by predicate. * * @static * @memberOf _ diff --git a/remove.js b/remove.js index c929c55cf..9682cce30 100644 --- a/remove.js +++ b/remove.js @@ -3,10 +3,11 @@ import basePullAt from './_basePullAt'; /** * Removes all elements from `array` that `predicate` returns truthy for - * and returns an array of the removed elements. The predicate is invoked with - * three arguments: (value, index, array). + * and returns an array of the removed elements. The predicate is invoked + * with three arguments: (value, index, array). * - * **Note:** Unlike `_.filter`, this method mutates `array`. + * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull` + * to pull elements from an array by value. * * @static * @memberOf _ diff --git a/times.js b/times.js index efdcfb016..33bb868d9 100644 --- a/times.js +++ b/times.js @@ -12,8 +12,8 @@ var MAX_ARRAY_LENGTH = 4294967295; var nativeMin = Math.min; /** - * Invokes the iteratee function `n` times, returning an array of the results - * of each invocation. The iteratee is invoked with one argument; (index). + * Invokes the iteratee `n` times, returning an array of the results of + * each invocation. The iteratee is invoked with one argument; (index). * * @static * @memberOf _ diff --git a/transform.js b/transform.js index effc6d127..9f769ecf3 100644 --- a/transform.js +++ b/transform.js @@ -7,6 +7,9 @@ import isFunction from './isFunction'; import isObject from './isObject'; import isTypedArray from './isTypedArray'; +/** Built-in value references. */ +var getPrototypeOf = Object.getPrototypeOf; + /** * An alternative to `_.reduce`; this method transforms `object` to a new * `accumulator` object which is the result of running each of its own enumerable @@ -45,7 +48,7 @@ function transform(object, iteratee, accumulator) { if (isArr) { accumulator = isArray(object) ? new Ctor : []; } else { - accumulator = baseCreate(isFunction(Ctor) ? Ctor.prototype : undefined); + accumulator = isFunction(Ctor) ? baseCreate(getPrototypeOf(object)) : {}; } } else { accumulator = {};