UNPKG

@newdash/newdash

Version:

javascript/typescript utility library

25 lines (24 loc) 898 B
import { RecordIteratee } from "./types"; /** * 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 * @category Object * @param object The object to invert. * @param iteratee The iteratee invoked per element. * @returns Returns the new inverted object. * @example * * ```js * const object = { 'a': 1, 'b': 2, 'c': 1 } * * invertBy(object, value => `group${value}`) * // => { 'group1': ['a', 'c'], 'group2': ['b'] } * ``` */ export declare function invertBy<T = any>(object: Record<string, T>, iteratee: RecordIteratee<T, string>): Record<string, Array<string>>; export default invertBy;