The invertBy function from the lodash library creates an object composed of keys generated from the results of running each element of object through iteratee. The corresponding value of each key is an array of the inverted keys responsible for generating the inverted value. The iteratee is invoked with one argument: (value).
Here's an example of using invertBy function:
index.tsx184 chars13 lines
In the above example, invertBy function creates an object who's keys are unique values in the original object and values are the original object keys associated with the given value. This function can be useful for grouping objects that share a common property.
gistlibby LogSnag