invert-by

v4.17.15arrow_drop_down
v4.17.15
v4.17.11
STATUS
Passing
DOWNLOADS
129
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
4 years ago
SIZE
N/A
Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) of values.
2 contributors
Install invert-by as a package?
Copied
npm i @bit/lodash.lodash.invert-by
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.cloud
Component Example
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
toggle layout
No preview available
modifieddraft
chevron_left
chevron_right
invertBy (
object:Object,
iteratee:Function
) : Object

This method is like invert except that the inverted object is generated from the results of running each element of object thru iteratee. The corresponding inverted value of each inverted key is an array of keys responsible for generating the inverted value. The iteratee is invoked with one argument: (value).

Example
const object = { 'a': 1, 'b': 2, 'c': 1 }

invertBy(object, value => `group${value}`)
// => { 'group1': ['a', 'c'], 'group2': ['b'] }
Arguments
object: Object

The object to invert.

iteratee: Function

The iteratee invoked per element.

Returns
Object

Returns the new inverted object.

Help and resources