1 5
export class ObjectUtils {
2
  /**
3
   * Copy the values of all of the enumerable own properties from one or more source objects to a
4
   * target object. Returns the target object.
5
   * @param target The target object to copy to.
6
   * @param source The source object from which to copy properties.
7
   */
8
  static assign<T, U>(target: T, source: U): T & U;
9

10
  /**
11
   * Copy the values of all of the enumerable own properties from one or more source objects to a
12
   * target object. Returns the target object.
13
   * @param target The target object to copy to.
14
   * @param source1 The first source object from which to copy properties.
15
   * @param source2 The second source object from which to copy properties.
16
   */
17
  static assign<T, U, V>(target: T, source1: U, source2: V): T & U & V;
18

19
  /**
20
   * Copy the values of all of the enumerable own properties from one or more source objects to a
21
   * target object. Returns the target object.
22
   * @param target The target object to copy to.
23
   * @param source1 The first source object from which to copy properties.
24
   * @param source2 The second source object from which to copy properties.
25
   * @param source3 The third source object from which to copy properties.
26
   */
27
  static assign<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
28

29
  /**
30
   * Copy the values of all of the enumerable own properties from one or more source objects to a
31
   * target object. Returns the target object.
32
   * @param target The target object to copy to.
33
   * @param sources One or more source objects from which to copy properties
34
   */
35 5
  static assign(target: object, ...sources: any[]): any {
36 5
    for (const source of sources) {
37 5
      for (const prop of Object.getOwnPropertyNames(source)) {
38 5
          (target as any)[prop] = source[prop];
39
      }
40
    }
41
  }
42 5
}

Read our documentation on viewing source code .

Loading