Utility TypeScript @ 2.0.0-beta
    Preparing search index...

    Function mergeArgs

    Returns an updated version of defaults merged with the contents of inputs.

    Useful for parsing objects passed to functions with extra, optional options. Preserves all input properties.

    Overloaded for better typing dependent on recursion.

    0.1.0

    • Inputs can be undefined, and if so, the default is returned.

      Type Parameters

      • D extends object

        Default object type.

      Parameters

      • defaults: D

        Default values (if not specified in inputs).

      • Optionalinputs: undefined

        Overriding values (changes to make).

      • Optionalrecursive: boolean

        Optional. Whether to merge the object recursively. Default false.

      Returns D

      Resulting object with all the defaults and inputs keys with either default values or input values, as appropriate.

    • Passing recursive as false means that the input type must be a Partial (not RecursivePartial).

      Type Parameters

      • D extends object
      • I extends Partial<D>

      Parameters

      • defaults: D
      • inputs: I
      • Optionalrecursive: false

      Returns D & I

    • Passing recursive as true means that the input type may actually be a RecursivePartial.

      Type Parameters

      Parameters

      • defaults: D
      • inputs: I
      • recursive: true

      Returns D & I

    • Universal overload.

      Type Parameters

      Parameters

      • defaults: D
      • Optionalinputs: I
      • Optionalrecursive: boolean

      Returns D | D & I