Options
All
  • Public
  • Public/Protected
  • All
Menu

Module object/propSet

Index

References

Functions

References

Renames and re-exports propSet

Functions

  • propSet<K, V, O>(prop: K, val: V, obj: O): ReplaceType<O, K, V>
  • propSet<K, V>(prop: K, val: V): <O>(obj: O) => ReplaceType<O, K, V>
  • propSet<K>(prop: K): { <V, O>(val: V, obj: O): ReplaceType<O, K, V>; <V>(val: V): <O>(obj: O) => ReplaceType<O, K, V> }
  • Makes a shallow clone of an object, setting or overriding the specified property with the given value. All non-primitive properties are copied by reference.

    Note: If property in the object is equal to value by reference then function just returns object without changes

    example
     propSet('c', 3, {a: 1, b: 2}); //=> {a: 1, b: 2, c: 3}
    

    Type parameters

    • K: string | number | symbol

    • V

    • O

    Parameters

    • prop: K

      The property name to set

    • val: V

      The new value

    • obj: O

      The object to clone

    Returns ReplaceType<O, K, V>

    A new object equivalent to the original except for the changed property.

  • Makes a shallow clone of an object, setting or overriding the specified property with the given value. All non-primitive properties are copied by reference.

    Note: If property in the object is equal to value by reference then function just returns object without changes

    example
     propSet('c', 3, {a: 1, b: 2}); //=> {a: 1, b: 2, c: 3}
    

    Type parameters

    • K: string | number | symbol

    • V

    Parameters

    • prop: K

      The property name to set

    • val: V

      The new value

    Returns <O>(obj: O) => ReplaceType<O, K, V>

    A new object equivalent to the original except for the changed property.

  • Makes a shallow clone of an object, setting or overriding the specified property with the given value. All non-primitive properties are copied by reference.

    Note: If property in the object is equal to value by reference then function just returns object without changes

    example
     propSet('c', 3, {a: 1, b: 2}); //=> {a: 1, b: 2, c: 3}
    

    Type parameters

    • K: string | number | symbol

    Parameters

    • prop: K

      The property name to set

    Returns { <V, O>(val: V, obj: O): ReplaceType<O, K, V>; <V>(val: V): <O>(obj: O) => ReplaceType<O, K, V> }

    A new object equivalent to the original except for the changed property.

Generated using TypeDoc