UNPKG

@newdash/newdash

Version:

javascript/typescript utility library

27 lines (26 loc) 1.01 kB
import { ArrayIteratee, RecordIteratee } from "./types"; /** * Creates a flattened array of values by running each element in `collection` * thru `iteratee` and flattening the mapped results. The iteratee is invoked * with three arguments: (value, index|key, collection). * * @since 5.4.0 * @category Collection * @param collection The collection to iterate over. * @param iteratee The function invoked per iteration. * @returns Returns the new flattened array. * @see [[flatMapDeep]],[[flatMapDepth]],[[flatten]],[[flattenDeep]],[[flattenDepth]],[[map]],[[mapKeys]],[[mapValues]] * @example * * ```js * function duplicate(n) { * return [n, n] * } * * flatMap([1, 2], duplicate) * // => [1, 1, 2, 2] * ``` */ export declare function flatMap<T, R = any>(collection: Array<T>, iteratee?: ArrayIteratee<T, Array<T>>): Array<R>; export declare function flatMap<T, R = any>(collection: Record<string, T>, iteratee?: RecordIteratee<T, Record<string, T>>): Array<R>; export default flatMap;