1 |
3a515b92
|
cagy
|
var baseForOwn = require('./_baseForOwn');
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* The base implementation of `_.invert` and `_.invertBy` which inverts
|
5 |
|
|
* `object` with values transformed by `iteratee` and set by `setter`.
|
6 |
|
|
*
|
7 |
|
|
* @private
|
8 |
|
|
* @param {Object} object The object to iterate over.
|
9 |
|
|
* @param {Function} setter The function to set `accumulator` values.
|
10 |
|
|
* @param {Function} iteratee The iteratee to transform values.
|
11 |
|
|
* @param {Object} accumulator The initial inverted object.
|
12 |
|
|
* @returns {Function} Returns `accumulator`.
|
13 |
|
|
*/
|
14 |
|
|
function baseInverter(object, setter, iteratee, accumulator) {
|
15 |
|
|
baseForOwn(object, function(value, key, object) {
|
16 |
|
|
setter(accumulator, iteratee(value), key, object);
|
17 |
|
|
});
|
18 |
|
|
return accumulator;
|
19 |
|
|
}
|
20 |
|
|
|
21 |
|
|
module.exports = baseInverter;
|