source: node_modules/es-toolkit/dist/compat/array/flatMapDeep.d.ts

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 3.5 KB
Line 
1import { ListIterator } from '../_internal/ListIterator.js';
2import { ListOfRecursiveArraysOrValues } from '../_internal/ListOfRecursiveArraysOrValues.js';
3import { ObjectIterator } from '../_internal/ObjectIterator.js';
4
5/**
6 * Creates a flattened array of values by running each element through iteratee and recursively flattening the mapped results.
7 *
8 * @template T
9 * @param {Record<string, RecursiveArray<T> | T> | Record<number, RecursiveArray<T> | T> | null | undefined} collection - The collection to iterate over.
10 * @returns {T[]} Returns the new deeply flattened array.
11 *
12 * @example
13 * const obj = { a: [[1, 2]], b: [[[3]]] };
14 * flatMapDeep(obj);
15 * // => [1, 2, 3]
16 */
17declare function flatMapDeep<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 recursively flattening the mapped results.
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 * @returns {R[]} Returns the new deeply flattened array.
25 *
26 * @example
27 * function duplicate(n) {
28 * return [[[n, n]]];
29 * }
30 *
31 * flatMapDeep([1, 2], duplicate);
32 * // => [1, 1, 2, 2]
33 */
34declare function flatMapDeep<T, R>(collection: ArrayLike<T> | null | undefined, iteratee: ListIterator<T, ListOfRecursiveArraysOrValues<R> | R>): R[];
35/**
36 * Creates a flattened array of values by running each element through iteratee and recursively flattening the mapped results.
37 *
38 * @template T, R
39 * @param {T | null | undefined} collection - The object to iterate over.
40 * @param {ObjectIterator<T, RecursiveArray<R> | R>} iteratee - The function invoked per iteration.
41 * @returns {R[]} Returns the new deeply flattened array.
42 *
43 * @example
44 * const obj = { a: 1, b: 2 };
45 * flatMapDeep(obj, (value, key) => [[[key, value]]]);
46 * // => ['a', 1, 'b', 2]
47 */
48declare function flatMapDeep<T extends object, R>(collection: T | null | undefined, iteratee: ObjectIterator<T, ListOfRecursiveArraysOrValues<R> | R>): R[];
49/**
50 * Creates a flattened array of values by running each element through iteratee and recursively flattening the mapped results.
51 *
52 * @param {object | null | undefined} collection - The collection to iterate over.
53 * @param {string} iteratee - The property name to use as iteratee.
54 * @returns {any[]} Returns the new deeply flattened array.
55 *
56 * @example
57 * const users = [
58 * { user: 'barney', hobbies: [['hiking', 'coding']] },
59 * { user: 'fred', hobbies: [['reading']] }
60 * ];
61 * flatMapDeep(users, 'hobbies');
62 * // => ['hiking', 'coding', 'reading']
63 */
64declare function flatMapDeep(collection: object | null | undefined, iteratee: string): any[];
65/**
66 * Creates a flattened array of values by running each element through iteratee and recursively flattening the mapped results.
67 *
68 * @param {object | null | undefined} collection - The collection to iterate over.
69 * @param {object} iteratee - The object properties to match.
70 * @returns {boolean[]} Returns the new deeply flattened array.
71 *
72 * @example
73 * const users = [
74 * { user: 'barney', active: [true, false] },
75 * { user: 'fred', active: [false] }
76 * ];
77 * flatMapDeep(users, { active: [false] });
78 * // => [false]
79 */
80declare function flatMapDeep(collection: object | null | undefined, iteratee: object): boolean[];
81
82export { flatMapDeep };
Note: See TracBrowser for help on using the repository browser.