mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 17:47:49 +00:00
Consolidate invert modules.
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
import baseForOwn from './baseForOwn.js';
|
||||
|
||||
/**
|
||||
* The base implementation of `invert` and `invertBy` which inverts
|
||||
* `object` with values transformed by `iteratee` and set by `setter`.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to iterate over.
|
||||
* @param {Function} setter The function to set `accumulator` values.
|
||||
* @param {Function} iteratee The iteratee to transform values.
|
||||
* @param {Object} accumulator The initial inverted object.
|
||||
* @returns {Function} Returns `accumulator`.
|
||||
*/
|
||||
function baseInverter(object, setter, iteratee, accumulator) {
|
||||
baseForOwn(object, (value, key, object) => {
|
||||
setter(accumulator, iteratee(value), key, object);
|
||||
});
|
||||
return accumulator;
|
||||
}
|
||||
|
||||
export default baseInverter;
|
||||
@@ -1,14 +0,0 @@
|
||||
import baseInverter from './.internal/baseInverter.js';
|
||||
|
||||
/**
|
||||
* Creates a function like `invertBy`.
|
||||
*
|
||||
* @private
|
||||
* @param {Function} setter The function to set accumulator values.
|
||||
* @returns {Function} Returns the new inverter function.
|
||||
*/
|
||||
function createInverter(setter) {
|
||||
return (object, iteratee) => baseInverter(object, setter, iteratee, {});
|
||||
}
|
||||
|
||||
export default createInverter;
|
||||
Reference in New Issue
Block a user