mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 17:07:49 +00:00
Remove semicolons.
This commit is contained in:
22
invertBy.js
22
invertBy.js
@@ -1,7 +1,7 @@
|
||||
import baseForOwn from './baseForOwn.js';
|
||||
import baseForOwn from './baseForOwn.js'
|
||||
|
||||
/** Used to check objects for own properties. */
|
||||
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
const hasOwnProperty = Object.prototype.hasOwnProperty
|
||||
|
||||
/**
|
||||
* This method is like `invert` except that the inverted object is generated
|
||||
@@ -17,22 +17,22 @@ const hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
* @returns {Object} Returns the new inverted object.
|
||||
* @example
|
||||
*
|
||||
* const object = { 'a': 1, 'b': 2, 'c': 1 };
|
||||
* const object = { 'a': 1, 'b': 2, 'c': 1 }
|
||||
*
|
||||
* invertBy(object, value => `group${ value }`);
|
||||
* invertBy(object, value => `group${ value }`)
|
||||
* // => { 'group1': ['a', 'c'], 'group2': ['b'] }
|
||||
*/
|
||||
function invertBy(object, iteratee) {
|
||||
const result = {};
|
||||
const result = {}
|
||||
baseForOwn(object, (value, key) => {
|
||||
value = iteratee(value);
|
||||
value = iteratee(value)
|
||||
if (hasOwnProperty.call(result, value)) {
|
||||
result[value].push(key);
|
||||
result[value].push(key)
|
||||
} else {
|
||||
result[value] = [key];
|
||||
result[value] = [key]
|
||||
}
|
||||
});
|
||||
return result;
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
export default invertBy;
|
||||
export default invertBy
|
||||
|
||||
Reference in New Issue
Block a user