@dxos/echo
    Preparing search index...

    Variable setValueConst

    setValue: (
        obj: Obj.Mutable<Obj.Unknown>,
        path: readonly (string | number)[],
        value: any,
    ) => void = ...

    Set a deeply nested property on an object, using the object's schema to determine whether to initialize nested data as an empty object or array.

    Similar to lodash.set and setDeep from @dxos/util, but schema-aware. Must be called within an Obj.update callback.

    NOTE: TypeScript's structural typing allows readonly objects to be passed to Mutable<T> parameters, so there is no compile-time error. Enforcement is runtime-only.

    Type declaration

      • (
            obj: Obj.Mutable<Obj.Unknown>,
            path: readonly (string | number)[],
            value: any,
        ): void
      • Parameters

        • obj: Obj.Mutable<Obj.Unknown>

          The mutable ECHO object to set the property on.

        • path: readonly (string | number)[]

          Path to the property (array of keys).

        • value: any

          Value to set.

        Returns void

        The value that was set.

    const person = Obj.make(Person, { name: 'John' });
    // Person schema has: addresses: Schema.Array(Address)
    Obj.update(person, (obj) => {
    Obj.setValue(obj, ['addresses', 0, 'street'], '123 Main St');
    });
    // Creates: person.addresses = [{ street: '123 Main St' }]

    O(path length) schema-guided walk; each missing level scans its schema properties once.