| 1 | import { PropertyPath } from '../_internal/PropertyPath.mjs';
|
|---|
| 2 |
|
|---|
| 3 | /**
|
|---|
| 4 | * Updates the value at the specified path of the given object using an updater function and a customizer.
|
|---|
| 5 | * If any part of the path does not exist, it will be created.
|
|---|
| 6 | *
|
|---|
| 7 | * @template T - The type of the object.
|
|---|
| 8 | * @param {T} object - The object to modify.
|
|---|
| 9 | * @param {PropertyPath} path - The path of the property to update.
|
|---|
| 10 | * @param {(oldValue: any) => any} updater - The function to produce the updated value.
|
|---|
| 11 | * @param {(value: any, key: string, object: T) => any} customizer - The function to customize the update process.
|
|---|
| 12 | * @returns {T} - The modified object.
|
|---|
| 13 | *
|
|---|
| 14 | * @example
|
|---|
| 15 | * const object = { 'a': [{ 'b': { 'c': 3 } }] };
|
|---|
| 16 | * updateWith(object, 'a[0].b.c', (n) => n * n);
|
|---|
| 17 | * // => { 'a': [{ 'b': { 'c': 9 } }] }
|
|---|
| 18 | */
|
|---|
| 19 | declare function updateWith<T extends object>(object: T, path: PropertyPath, updater: (oldValue: any) => any, customizer?: (value: any, key: string, object: T) => any): T;
|
|---|
| 20 | /**
|
|---|
| 21 | * Updates the value at the specified path of the given object using an updater function and a customizer.
|
|---|
| 22 | * If any part of the path does not exist, it will be created.
|
|---|
| 23 | *
|
|---|
| 24 | * @template T - The type of the object.
|
|---|
| 25 | * @template R - The type of the return value.
|
|---|
| 26 | * @param {T} object - The object to modify.
|
|---|
| 27 | * @param {PropertyPath} path - The path of the property to update.
|
|---|
| 28 | * @param {(oldValue: any) => any} updater - The function to produce the updated value.
|
|---|
| 29 | * @param {(value: any, key: string, object: T) => any} customizer - The function to customize the update process.
|
|---|
| 30 | * @returns {R} - The modified object.
|
|---|
| 31 | *
|
|---|
| 32 | * @example
|
|---|
| 33 | * const object = { 'a': [{ 'b': { 'c': 3 } }] };
|
|---|
| 34 | * updateWith(object, 'a[0].b.c', (n) => n * n);
|
|---|
| 35 | * // => { 'a': [{ 'b': { 'c': 9 } }] }
|
|---|
| 36 | */
|
|---|
| 37 | declare function updateWith<T extends object, R>(object: T, path: PropertyPath, updater: (oldValue: any) => any, customizer?: (value: any, key: string, object: T) => any): R;
|
|---|
| 38 |
|
|---|
| 39 | export { updateWith };
|
|---|