* 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 `accumulator` i
(object, iteratee, accumulator)
| 13885 | * // => { '1': ['a', 'c'], '2': ['b'] } |
| 13886 | */ |
| 13887 | function transform(object, iteratee, accumulator) { |
| 13888 | var isArr = isArray(object), |
| 13889 | isArrLike = isArr || isBuffer(object) || isTypedArray(object); |
| 13890 | |
| 13891 | iteratee = getIteratee(iteratee, 4); |
| 13892 | if (accumulator == null) { |
| 13893 | var Ctor = object && object.constructor; |
| 13894 | if (isArrLike) { |
| 13895 | accumulator = isArr ? new Ctor : []; |
| 13896 | } |
| 13897 | else if (isObject(object)) { |
| 13898 | accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {}; |
| 13899 | } |
| 13900 | else { |
| 13901 | accumulator = {}; |
| 13902 | } |
| 13903 | } |
| 13904 | (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) { |
| 13905 | return iteratee(accumulator, value, index, object); |
| 13906 | }); |
| 13907 | return accumulator; |
| 13908 | } |
| 13909 | |
| 13910 | /** |
| 13911 | * Removes the property at `path` of `object`. |
no test coverage detected