source: node_modules/es-toolkit/dist/compat/array/zipObjectDeep.d.mts

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

Added visualizations

  • Property mode set to 100644
File size: 1.7 KB
Line 
1import { PropertyPath } from '../_internal/PropertyPath.mjs';
2
3/**
4 * Creates a deeply nested object given arrays of paths and values.
5 *
6 * This function takes two arrays: one containing arrays of property paths, and the other containing corresponding values.
7 * It returns a new object where paths from the first array are used as key paths to set values, with corresponding elements from the second array as values.
8 * Paths can be dot-separated strings or arrays of property names.
9 *
10 * If the `keys` array is longer than the `values` array, the remaining keys will have `undefined` as their values.
11 *
12 * @template P - The type of property paths.
13 * @template V - The type of values corresponding to the property paths.
14 * @param {ArrayLike<P | P[]>} keys - An array of property paths, each path can be a dot-separated string or an array of property names.
15 * @param {ArrayLike<V>} values - An array of values corresponding to the property paths.
16 * @returns {Record<P, V>} A new object composed of the given property paths and values.
17 *
18 * @example
19 * const paths = ['a.b.c', 'd.e.f'];
20 * const values = [1, 2];
21 * const result = zipObjectDeep(paths, values);
22 * // result will be { a: { b: { c: 1 } }, d: { e: { f: 2 } } }
23 *
24 * @example
25 * const paths = [['a', 'b', 'c'], ['d', 'e', 'f']];
26 * const values = [1, 2];
27 * const result = zipObjectDeep(paths, values);
28 * // result will be { a: { b: { c: 1 } }, d: { e: { f: 2 } } }
29 *
30 * @example
31 * const paths = ['a.b[0].c', 'a.b[1].d'];
32 * const values = [1, 2];
33 * const result = zipObjectDeep(paths, values);
34 * // result will be { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
35 */
36declare function zipObjectDeep(keys?: ArrayLike<PropertyPath>, values?: ArrayLike<any>): object;
37
38export { zipObjectDeep };
Note: See TracBrowser for help on using the repository browser.