object.d.ts 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. type PropertyName = string | number | symbol;
  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. *
  6. * @param target The target object to copy to.
  7. * @param source The source object from which to copy properties.
  8. */
  9. export function assign<T, U>(target: T, source: U): T & U;
  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. *
  14. * @param target The target object to copy to.
  15. * @param source1 The first source object from which to copy properties.
  16. * @param source2 The second source object from which to copy properties.
  17. */
  18. export function assign<T, U, V>(target: T, source1: U, source2: V): T & U & V;
  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. *
  23. * @param target The target object to copy to.
  24. * @param source1 The first source object from which to copy properties.
  25. * @param source2 The second source object from which to copy properties.
  26. * @param source3 The third source object from which to copy properties.
  27. */
  28. export function assign<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
  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. *
  33. * @param target The target object to copy to.
  34. * @param sources One or more source objects from which to copy properties
  35. */
  36. export function assign<T>(target: T, ...sources: any[]): T;
  37. /**
  38. * Gets a nested property of a given object, with an optional default value.
  39. *
  40. * @param target The target of the get operation.
  41. * @param path The path to the nested value.
  42. * @param defaultValue The result to return if the property does not exist.
  43. *
  44. * @return any
  45. */
  46. export function get(target: any, path: (string|number)[], defaultValue?: any): any;
  47. /**
  48. * Sets a nested property of a given object to the specified value.
  49. *
  50. * This mutates the object and returns it.
  51. *
  52. * @param target The target of the set operation.
  53. * @param path The path to the nested value.
  54. * @param value The value to set.
  55. *
  56. * @return the element
  57. */
  58. export function set<T>(target: T, path: PropertyName[], value: any): T;
  59. /**
  60. * Pick properties from the given target.
  61. *
  62. * @param target
  63. * @param properties
  64. *
  65. * @return
  66. */
  67. export function pick<T, V extends keyof T>(target: T, properties: Array<V>): Pick<T, V>;
  68. /**
  69. * Pick properties from the given target.
  70. *
  71. * @param target
  72. * @param properties
  73. *
  74. * @return
  75. */
  76. export function pick<T, V extends PropertyName[]>(target: T, properties: V): Partial<T>;
  77. /**
  78. * Pick all target properties, excluding the given ones.
  79. *
  80. * @param target
  81. * @param properties
  82. *
  83. * @return target
  84. */
  85. export function omit<T, V extends keyof T>(target: T, properties: V): Omit<T, V>;
  86. /**
  87. * Pick all target properties, excluding the given ones.
  88. *
  89. * @param target
  90. * @param properties
  91. *
  92. * @return target
  93. */
  94. export function omit<T, V extends PropertyName[]>(target: T, properties: V): Pick<T, Exclude<keyof T, V[number]>>;
  95. /**
  96. * Copy the values of all of the enumerable own properties from one or more source objects to a
  97. * target object. Returns the target object.
  98. * @param target The target object to copy to.
  99. * @param sources One or more source objects from which to copy properties
  100. */
  101. export function merge(target: object, ...sources: any[]): any;