* An alternative to `_.reduce`; this method transforms `object` to a new * `accumulator` object which is the result of running each of its own * enumerable string keyed properties thru `iteratee`, with each invocation * potentially mutating the `accumulator` object. If `ac
(object, iteratee, accumulator)
| 24412 | * // => { '1': ['a', 'c'], '2': ['b'] } |
| 24413 | */ |
| 24414 | function transform(object, iteratee, accumulator) { |
| 24415 | var isArr = isArray(object), |
| 24416 | isArrLike = isArr || isBuffer(object) || isTypedArray(object); |
| 24417 | |
| 24418 | iteratee = getIteratee(iteratee, 4); |
| 24419 | if (accumulator == null) { |
| 24420 | var Ctor = object && object.constructor; |
| 24421 | if (isArrLike) { |
| 24422 | accumulator = isArr ? new Ctor : []; |
| 24423 | } |
| 24424 | else if (isObject(object)) { |
| 24425 | accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {}; |
| 24426 | } |
| 24427 | else { |
| 24428 | accumulator = {}; |
| 24429 | } |
| 24430 | } |
| 24431 | (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) { |
| 24432 | return iteratee(accumulator, value, index, object); |
| 24433 | }); |
| 24434 | return accumulator; |
| 24435 | } |
| 24436 | |
| 24437 | /** |
| 24438 | * Removes the property at `path` of `object`. |
no test coverage detected