@newdash/newdash
Version:
javascript/typescript utility library
32 lines (31 loc) • 1.04 kB
TypeScript
/**
* @ignore
*/
interface Iteratee<K, V, C> {
(value?: V, index?: K, collection?: C): any;
}
/**
* This method is like `flatMap` except that it recursively flattens the
* mapped results up to `depth` times.
*
* @since 5.4.0
* @category Collection
* @param collection The collection to iterate over.
* @param iteratee The function invoked per iteration.
* @param depth The maximum recursion depth.
* @returns Returns the new flattened array.
* @see [[flatMap]],[[flatMapDepth]],[[flatten]],[[flattenDeep]],[[flattenDepth]],[[map]],[[mapKeys]],[[mapValues]]
* @example
*
* ```js
* function duplicate(n) {
* return [[[n, n]]]
* }
*
* flatMapDepth([1, 2], duplicate, 2)
* // => [[1, 1], [2, 2]]
* ```
*/
declare function flatMapDepth<T, R = any>(collection: Array<T>, iteratee?: Iteratee<number, T, Array<T>>, depth?: number): Array<R>;
declare function flatMapDepth<T, R = any>(collection: Record<string, T>, iteratee?: Iteratee<string, T, Record<string, T>>, depth?: number): Array<R>;
export default flatMapDepth;