Function set

  • Sets the value on the specified path in source value. If the path in the source doesn't exist it will be created. Note, that we don't know what is the type of the object at runtime. Due to this, if the path value is number, we create an array, otherwise object.

    Source value can be nullable or undefinable, and path is treated as if the source (and all intermediate) values are required (because nullable and undefinable types can't have keys).

    Path supports up to 5 elements. This means, you are not able to use this helper if you need more.

    Return type will be the same as the source type, where any optional values along the path are made required (because they are created).

    Returns

    source value with value on path set

    Type Parameters

    • T

    • K1 extends string | number | symbol

    • R

    Parameters

    • source: Optional<T>

      source, in which the nested value should be set.

    • path: [K1]

      path array of the nested value in the source

    • value: R

      value to be set in source on specified path

    Returns Set1<T, K1, R>

  • Sets the value on the specified path in source value. If the path in the source doesn't exist it will be created. Note, that we don't know what is the type of the object at runtime. Due to this, if the path value is number, we create an array, otherwise object.

    Source value can be nullable or undefinable, and path is treated as if the source (and all intermediate) values are required (because nullable and undefinable types can't have keys).

    Path supports up to 5 elements. This means, you are not able to use this helper if you need more.

    Return type will be the same as the source type, where any optional values along the path are made required (because they are created).

    Returns

    source value with value on path set

    Type Parameters

    • T

    • K1 extends string | number | symbol

    • K2 extends string | number | symbol

    • R

    Parameters

    • source: Optional<T>

      source, in which the nested value should be set.

    • path: [K1, K2]

      path array of the nested value in the source

    • value: R

      value to be set in source on specified path

    Returns Set2<T, K1, K2, R>

  • Sets the value on the specified path in source value. If the path in the source doesn't exist it will be created. Note, that we don't know what is the type of the object at runtime. Due to this, if the path value is number, we create an array, otherwise object.

    Source value can be nullable or undefinable, and path is treated as if the source (and all intermediate) values are required (because nullable and undefinable types can't have keys).

    Path supports up to 5 elements. This means, you are not able to use this helper if you need more.

    Return type will be the same as the source type, where any optional values along the path are made required (because they are created).

    Returns

    source value with value on path set

    Type Parameters

    • T

    • K1 extends string | number | symbol

    • K2 extends string | number | symbol

    • K3 extends string | number | symbol

    • R

    Parameters

    • source: Optional<T>

      source, in which the nested value should be set.

    • path: [K1, K2, K3]

      path array of the nested value in the source

    • value: R

      value to be set in source on specified path

    Returns Set3<T, K1, K2, K3, R>

  • Sets the value on the specified path in source value. If the path in the source doesn't exist it will be created. Note, that we don't know what is the type of the object at runtime. Due to this, if the path value is number, we create an array, otherwise object.

    Source value can be nullable or undefinable, and path is treated as if the source (and all intermediate) values are required (because nullable and undefinable types can't have keys).

    Path supports up to 5 elements. This means, you are not able to use this helper if you need more.

    Return type will be the same as the source type, where any optional values along the path are made required (because they are created).

    Returns

    source value with value on path set

    Type Parameters

    • T

    • K1 extends string | number | symbol

    • K2 extends string | number | symbol

    • K3 extends string | number | symbol

    • K4 extends string | number | symbol

    • R

    Parameters

    • source: Optional<T>

      source, in which the nested value should be set.

    • path: [K1, K2, K3, K4]

      path array of the nested value in the source

    • value: R

      value to be set in source on specified path

    Returns Set4<T, K1, K2, K3, K4, R>

  • Sets the value on the specified path in source value. If the path in the source doesn't exist it will be created. Note, that we don't know what is the type of the object at runtime. Due to this, if the path value is number, we create an array, otherwise object.

    Source value can be nullable or undefinable, and path is treated as if the source (and all intermediate) values are required (because nullable and undefinable types can't have keys).

    Path supports up to 5 elements. This means, you are not able to use this helper if you need more.

    Return type will be the same as the source type, where any optional values along the path are made required (because they are created).

    Returns

    source value with value on path set

    Type Parameters

    • T

    • K1 extends string | number | symbol

    • K2 extends string | number | symbol

    • K3 extends string | number | symbol

    • K4 extends string | number | symbol

    • K5 extends string | number | symbol

    • R

    Parameters

    • source: Optional<T>

      source, in which the nested value should be set.

    • path: [K1, K2, K3, K4, K5]

      path array of the nested value in the source

    • value: Exclude<Exclude<Exclude<Exclude<T[K1], undefined | null>[K2], undefined | null>[K3], undefined | null>[K4], undefined | null>[K5]

      value to be set in source on specified path

    Returns Set5<T, K1, K2, K3, K4, K5, R>

Generated using TypeDoc