* 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 a callback, with each callback execution * potentially mutating the `accumulator` object. The callback is bound
(object, callback, accumulator, thisArg)
| 38002 | * // => { 'a': 3, 'b': 6, 'c': 9 } |
| 38003 | */ |
| 38004 | function transform(object, callback, accumulator, thisArg) { |
| 38005 | var isArr = isArray(object); |
| 38006 | if (accumulator == null) { |
| 38007 | if (isArr) { |
| 38008 | accumulator = []; |
| 38009 | } else { |
| 38010 | var ctor = object && object.constructor, |
| 38011 | proto = ctor && ctor.prototype; |
| 38012 | |
| 38013 | accumulator = baseCreate(proto); |
| 38014 | } |
| 38015 | } |
| 38016 | if (callback) { |
| 38017 | callback = lodash.createCallback(callback, thisArg, 4); |
| 38018 | (isArr ? forEach : forOwn)(object, function(value, index, object) { |
| 38019 | return callback(accumulator, value, index, object); |
| 38020 | }); |
| 38021 | } |
| 38022 | return accumulator; |
| 38023 | } |
| 38024 | |
| 38025 | /** |
| 38026 | * Creates an array composed of the own enumerable property values of `object`. |
nothing calls this directly
no test coverage detected