import type { DeepPath, OptPathVal, Path, Path0, Path1, Path2, Path3, Path4, Path5, Path6, Path7, Path8, PathVal } from "@thi.ng/api"; import type { UpdateFn } from "./api.js"; /** * Similar to {@link setInUnsafe}, but applies given function to current path * value (incl. any additional/optional arguments passed to `updateIn`) and uses * result as new value. Does **not** modify original state. * * @remarks * Non-typechecked version of {@link updateIn}. The type parameter `T` can be * used to indicate the type of the nested value to be updated (default: `any`). * * @example * ```ts tangle:../export/update-in-unsafe.ts * import { updateIn, updateInUnsafe } from "@thi.ng/paths"; * * const add = (x: number, y: number) => x + y; * * console.log( * updateInUnsafe({ a: { b: { c: 23 } } }, "a.b.c", add, 10) * ); * // { a: { b: { c: 33 } } } * * // type checked * console.log( * updateIn({ a: { b: { c: 23 } } }, ["a", "b", "c"], add, 10) * ); * // { a: { b: { c: 33 } } } * * // type error (value at "a.b" is not a number) * // updateIn({ a: { b: { c: 23 } } }, ["a", "b"], add, 10) * ``` * * @param state - state to update * @param path - update path * @param fn - update function * @param args - optional args for `fn` */ export declare const updateInUnsafe: (state: any, path: Path, fn: UpdateFn, ...args: any[]) => any; /** * Type checked version of {@link updateIn}. Only the first 8 path * levels are type checked. * * @param state - * @param path - * @param fn - */ export declare function updateIn(state: T, path: Path0, fn: UpdateFn): T; export declare function updateIn(state: T, path: Path1, fn: UpdateFn, PathVal>, ...args: any[]): T; export declare function updateIn(state: T, path: Path2, fn: UpdateFn, PathVal>, ...args: any[]): T; export declare function updateIn(state: T, path: Path3, fn: UpdateFn, PathVal>, ...args: any[]): T; export declare function updateIn(state: T, path: Path4, fn: UpdateFn, PathVal>, ...args: any[]): T; export declare function updateIn(state: T, path: Path5, fn: UpdateFn, PathVal>, ...args: any[]): T; export declare function updateIn(state: T, path: Path6, fn: UpdateFn, PathVal>, ...args: any[]): T; export declare function updateIn(state: T, path: Path7, fn: UpdateFn, PathVal>, ...args: any[]): T; export declare function updateIn(state: T, path: Path8, fn: UpdateFn, PathVal>, ...args: any[]): T; export declare function updateIn(state: T, path: DeepPath, fn: UpdateFn, ...args: any[]): T; //# sourceMappingURL=update-in.d.ts.map