import { t as ObjectPath } from "./ObjectPath-CRdxsVAG.cjs"; import { Get } from "type-fest"; //#region src/types/_internal/RequiredKeysDeep.d.ts /** * Gets all elements except for head in an array * @example * Tail<[1, 2, 3]>; // [2, 3] */ type Tail = T extends [unknown, ...infer Rest] ? Rest : never; /** * Returns Tail if first element of T matches P. Somehow resolves issues with * union types, but unsure how; @see {@link https://stackoverflow.com/a/57837897/1105281} */ type TailUnion = T extends readonly unknown[] ? T[0] extends P ? Tail : never : never; /** * Converts a string like "a.b.c" to an array ["a", "b", "c"] */ type PathToStringArray = T extends `${infer Head}.${infer Tail}` ? [...PathToStringArray, ...PathToStringArray] : [T]; /** * For any object, enforces that the keys provided are all present; paths are * expressed as lists of keys in the order you would access them on an object; * for instance, for an object called obj, obj.a.b.c would be represented as * ["a", "b", "c"] * @see RequireKeysDeep for usage */ type RequireKeysDeepArray = TObject extends object ? Omit> & Required<{ [K in Extract]: NonNullable>> }> : TObject; /** * For any object, enforces that the keys provided are all present; works with * deeply nested syntax, by using period (`.`) as a delimiter. * @example * ```ts * type Foo = { a?: 2, b?: { c?: 3, d: 4 } } * type A = RequireKeysDeep; // {a: 2, b?: { c?: 3, d: 4 } } * type B = RequireKeysDeep; // {a?: 2, b: { c?: 3, d: 4 } } * type BC = RequireKeysDeep; // {a?: 2, b: { c: 3, d: 4 } } * type ABC = RequireKeysDeep; // {a: 2, b: { c: 3, d: 4 } } * ``` */ type RequireKeysDeep = RequireKeysDeepArray>; //#endregion //#region src/functions/set/set.d.ts /** * Sets a value at the specified (possibly nested) path in an object. * @template TObject The type of the object. * @template Path The type of the path. * @param object The object to set the value in. * @param path The path to set the value at. * @param value The value to set. * @example * ```ts * const object: { * foo?: { * bar?: { * anArray: string[]; * }; * } * }; * * set(object, 'foo.bar.anArray[0]', 'value'); * object.foo.bar.anArray[0]; // 'value' */ declare function set, Path extends ObjectPath>(object: TObject, path: Path, value: Get): asserts object is TObject & RequireKeysDeep; //#endregion export { set as t }; //# sourceMappingURL=set-BYmqLetA.d.cts.map