| 1 | import { ListIterator } from '../_internal/ListIterator.mjs';
|
|---|
| 2 | import { ListOfRecursiveArraysOrValues } from '../_internal/ListOfRecursiveArraysOrValues.mjs';
|
|---|
| 3 | import { ObjectIterator } from '../_internal/ObjectIterator.mjs';
|
|---|
| 4 |
|
|---|
| 5 | /**
|
|---|
| 6 | * Creates a flattened array of values by running each element through iteratee and flattening the mapped results up to depth times.
|
|---|
| 7 | *
|
|---|
| 8 | * @template T
|
|---|
| 9 | * @param {Record<string, ListOfRecursiveArraysOrValues<T> | T> | Record<number, ListOfRecursiveArraysOrValues<T> | T> | null | undefined} collection - The collection to iterate over.
|
|---|
| 10 | * @returns {T[]} Returns the new flattened array.
|
|---|
| 11 | *
|
|---|
| 12 | * @example
|
|---|
| 13 | * const obj = { a: [[1, 2]], b: [[[3]]] };
|
|---|
| 14 | * flatMapDepth(obj);
|
|---|
| 15 | * // => [1, 2, [3]]
|
|---|
| 16 | */
|
|---|
| 17 | declare function flatMapDepth<T>(collection: Record<string, ListOfRecursiveArraysOrValues<T> | T> | Record<number, ListOfRecursiveArraysOrValues<T> | T> | null | undefined): T[];
|
|---|
| 18 | /**
|
|---|
| 19 | * Creates a flattened array of values by running each element through iteratee and flattening the mapped results up to depth times.
|
|---|
| 20 | *
|
|---|
| 21 | * @template T, R
|
|---|
| 22 | * @param {ArrayLike<T> | null | undefined} collection - The collection to iterate over.
|
|---|
| 23 | * @param {ListIterator<T, RecursiveArray<R> | R>} iteratee - The function invoked per iteration.
|
|---|
| 24 | * @param {number} [depth=1] - The maximum recursion depth.
|
|---|
| 25 | * @returns {R[]} Returns the new flattened array.
|
|---|
| 26 | *
|
|---|
| 27 | * @example
|
|---|
| 28 | * function duplicate(n) {
|
|---|
| 29 | * return [[n, n]];
|
|---|
| 30 | * }
|
|---|
| 31 | *
|
|---|
| 32 | * flatMapDepth([1, 2], duplicate, 2);
|
|---|
| 33 | * // => [1, 1, 2, 2]
|
|---|
| 34 | */
|
|---|
| 35 | declare function flatMapDepth<T, R>(collection: ArrayLike<T> | null | undefined, iteratee: ListIterator<T, ListOfRecursiveArraysOrValues<R> | R>, depth?: number): R[];
|
|---|
| 36 | /**
|
|---|
| 37 | * Creates a flattened array of values by running each element through iteratee and flattening the mapped results up to depth times.
|
|---|
| 38 | *
|
|---|
| 39 | * @template T, R
|
|---|
| 40 | * @param {T | null | undefined} collection - The object to iterate over.
|
|---|
| 41 | * @param {ObjectIterator<T, RecursiveArray<R> | R>} iteratee - The function invoked per iteration.
|
|---|
| 42 | * @param {number} [depth=1] - The maximum recursion depth.
|
|---|
| 43 | * @returns {R[]} Returns the new flattened array.
|
|---|
| 44 | *
|
|---|
| 45 | * @example
|
|---|
| 46 | * const obj = { a: 1, b: 2 };
|
|---|
| 47 | * flatMapDepth(obj, (value, key) => [[key, value]], 2);
|
|---|
| 48 | * // => ['a', 1, 'b', 2]
|
|---|
| 49 | */
|
|---|
| 50 | declare function flatMapDepth<T extends object, R>(collection: T | null | undefined, iteratee: ObjectIterator<T, ListOfRecursiveArraysOrValues<R> | R>, depth?: number): R[];
|
|---|
| 51 | /**
|
|---|
| 52 | * Creates a flattened array of values by running each element through iteratee and flattening the mapped results up to depth times.
|
|---|
| 53 | *
|
|---|
| 54 | * @param {object | null | undefined} collection - The collection to iterate over.
|
|---|
| 55 | * @param {string} iteratee - The property name to use as iteratee.
|
|---|
| 56 | * @param {number} [depth=1] - The maximum recursion depth.
|
|---|
| 57 | * @returns {any[]} Returns the new flattened array.
|
|---|
| 58 | *
|
|---|
| 59 | * @example
|
|---|
| 60 | * const users = [
|
|---|
| 61 | * { user: 'barney', hobbies: [['hiking'], ['coding']] },
|
|---|
| 62 | * { user: 'fred', hobbies: [['reading']] }
|
|---|
| 63 | * ];
|
|---|
| 64 | * flatMapDepth(users, 'hobbies', 2);
|
|---|
| 65 | * // => ['hiking', 'coding', 'reading']
|
|---|
| 66 | */
|
|---|
| 67 | declare function flatMapDepth(collection: object | null | undefined, iteratee: string, depth?: number): any[];
|
|---|
| 68 | /**
|
|---|
| 69 | * Creates a flattened array of values by running each element through iteratee and flattening the mapped results up to depth times.
|
|---|
| 70 | *
|
|---|
| 71 | * @param {object | null | undefined} collection - The collection to iterate over.
|
|---|
| 72 | * @param {object} iteratee - The object properties to match.
|
|---|
| 73 | * @param {number} [depth=1] - The maximum recursion depth.
|
|---|
| 74 | * @returns {boolean[]} Returns the new flattened array.
|
|---|
| 75 | *
|
|---|
| 76 | * @example
|
|---|
| 77 | * const users = [
|
|---|
| 78 | * { user: 'barney', active: [[true], [false]] },
|
|---|
| 79 | * { user: 'fred', active: [[false]] }
|
|---|
| 80 | * ];
|
|---|
| 81 | * flatMapDepth(users, { active: [[false]] });
|
|---|
| 82 | * // => [false]
|
|---|
| 83 | */
|
|---|
| 84 | declare function flatMapDepth(collection: object | null | undefined, iteratee: object, depth?: number): boolean[];
|
|---|
| 85 |
|
|---|
| 86 | export { flatMapDepth };
|
|---|