* An alternative to `_.reduce`; this method transforms `object` to a new * `accumulator` object which is the result of running each of its own enumerable * properties through `iteratee`, with each invocation potentially mutating * the `accumulator` object. The `iteratee` is bound to `
(object, iteratee, accumulator, thisArg)
| 11375 | * // => { 'a': 3, 'b': 6 } |
| 11376 | */ |
| 11377 | function transform(object, iteratee, accumulator, thisArg) { |
| 11378 | var isArr = isArray(object) || isTypedArray(object); |
| 11379 | iteratee = getCallback(iteratee, thisArg, 4); |
| 11380 | |
| 11381 | if (accumulator == null) { |
| 11382 | if (isArr || isObject(object)) { |
| 11383 | var Ctor = object.constructor; |
| 11384 | if (isArr) { |
| 11385 | accumulator = isArray(object) ? new Ctor : []; |
| 11386 | } else { |
| 11387 | accumulator = baseCreate(isFunction(Ctor) && Ctor.prototype); |
| 11388 | } |
| 11389 | } else { |
| 11390 | accumulator = {}; |
| 11391 | } |
| 11392 | } |
| 11393 | (isArr ? arrayEach : baseForOwn)(object, function(value, index, object) { |
| 11394 | return iteratee(accumulator, value, index, object); |
| 11395 | }); |
| 11396 | return accumulator; |
| 11397 | } |
| 11398 | |
| 11399 | /** |
| 11400 | * Creates an array of the own enumerable property values of `object`. |
nothing calls this directly
no test coverage detected