import type { PathFn } from '../../global/path.js'; import type { PropFn } from '../../global/prop.js'; import type { Obj, Path } from '../../internal/types/tools/index.js'; declare global { interface ObjectConstructor { withW: { /** * Returns a new object with the specified property set to the given value. * * It is the same as `Object.with`, but with looser type restrictions. The `W` postfix stands for "wide". * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. * @param prop Property name or `prop` function representing the property to set. * @param value Value to set. * * @example * ```typescript * const obj = { a: 1, b: 2, c: { d: [{ e: 3 }] } }; * Object.withW(obj, 'a', 2); // => { a: 2, b: 2, c: { d: [{ e: 3 }] } } * Object.withW(obj, prop('a'), 2); // => { a: 2, b: 2, c: { d: [{ e: 3 }] } } * Object.withW(obj, path('c.d[0].e'), 4); // => { a: 1, b: 2, c: { d: [{ e: 4 }] } } * Object.withW(obj, ['c', 'd', '0', 'e'], 4); // => { a: 1, b: 2, c: { d: [{ e: 4 }] } } * ``` * * @see {@link Object.with} */ ( o: O, prop: K | PropFn, value: V, ): Obj.With>; /** * Returns a new object with the specified property set to the given value. * * It is the same as `Object.with`, but with looser type restrictions. The `W` postfix stands for "wide". * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. * @param path Property path or `path` function representing the property to set. * @param value Value to set. * * @example * ```typescript * const obj = { a: 1, b: 2, c: { d: [{ e: 3 }] } }; * Object.withW(obj, 'a', 2); // => { a: 2, b: 2, c: { d: [{ e: 3 }] } } * Object.withW(obj, prop('a'), 2); // => { a: 2, b: 2, c: { d: [{ e: 3 }] } } * Object.withW(obj, path('c.d[0].e'), 4); // => { a: 1, b: 2, c: { d: [{ e: 4 }] } } * Object.withW(obj, ['c', 'd', '0', 'e'], 4); // => { a: 1, b: 2, c: { d: [{ e: 4 }] } } * ``` * * @see {@link Object.with} */ < O extends object, const PP extends string | readonly PropertyKey[], const V, >( o: O, path: PathFn, value: V, ): Obj.With, Obj.WritableDeep>; /** * Returns a new object with the specified property set to the given value. * * It is the same as `Object.with`, but with looser type restrictions. The `W` postfix stands for "wide". * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. * @param path Property path or `path` function representing the property to set. * @param value Value to set. * * @example * ```typescript * const obj = { a: 1, b: 2, c: { d: [{ e: 3 }] } }; * Object.withW(obj, 'a', 2); // => { a: 2, b: 2, c: { d: [{ e: 3 }] } } * Object.withW(obj, prop('a'), 2); // => { a: 2, b: 2, c: { d: [{ e: 3 }] } } * Object.withW(obj, path('c.d[0].e'), 4); // => { a: 1, b: 2, c: { d: [{ e: 4 }] } } * Object.withW(obj, ['c', 'd', '0', 'e'], 4); // => { a: 1, b: 2, c: { d: [{ e: 4 }] } } * ``` * * @see {@link Object.with} */ ( o: O, path: PP, value: V, ): Obj.With, Obj.WritableDeep>; }; } } //# sourceMappingURL=withW.d.ts.map