Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Functions

Functions

merge

  • merge(...args: any[]): List
  • Can be used to merge multiple objects into each other. It will merge the objects recursively, so if your object looks like {a: {foo:'bar'}} and {a: {bar, 'baz'}} the result will be {a:{foo:'bar', bar: 'baz'}}.

    For the cool part: It works also for Array's, Map's, Set's in any order. So you may merge a Set with a Map, with an object and you may even nest objects, and Maps into each other.

    Arrays will be merged and values will be deduped if they come from different lists. Meaning: [1, 2, 3] + [1, 4, 6] = [1, 2, 3, 4, 6] BUT: [1, 2, 3] + [1, 4, 4, 4, 6] = [1, 2, 3, 4, 4, 4, 6]

    Note When merging an object into an array or a Set, you will loose your keys!

    The first argument type will determine the output type. So, if you supply an object, followed by an array, the output will be an object.

    Parameters

    • Rest ...args: any[]

    Returns List

Generated using TypeDoc