Options
All
  • Public
  • Public/Protected
  • All
Menu

Module invertBy

Index

References

Functions Object

References

Renames and re-exports __type

Object Functions

  • invertBy<T>(object: Record<string, T>, iteratee: RecordIteratee<T, string>): Record<string, string[]>
  • 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).

    since

    5.11.0

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

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

    Type parameters

    • T = any

    Parameters

    • object: Record<string, T>

      The object to invert.

    • iteratee: RecordIteratee<T, string>

      The iteratee invoked per element.

    Returns Record<string, string[]>

    Returns the new inverted object.