Function assign

  • assigns (deep copies) the values of all of the enumerable own properties from one or more sources to a target. The last value within the last sources object takes precedence over any previously encountered values.

    Type Parameters

    • T extends Record<PropertyKey, any>

      The type of the target object.

    • S extends Record<PropertyKey, any>[]

      The types of the sources objects.

    Parameters

    • target: T

      The target object to assign properties to.

    • Rest ...sources: [...S[]]

      An array of sources from which to deep copy properties.

    Returns T & Merge<S[number]>

    The assigned-to target object.

    Example

    assign nested properties:

    import { assign } from '@sgrud/core';

    assign(
    { one: { one: true }, two: false },
    { one: { key: null } },
    { two: true }
    );

    // { one: { one: true, key: null }, two: true }

Generated using TypeDoc