4b8ace8d4598147520e3f746adf9d2f773fe745e6c41899022ff8f5312ccc53376cb3fca0fc433e84a9d49a7f2c9c951320d64fe31830ac487ccf1f7caf31b 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. import _ = require("../index");
  2. declare module "../index" {
  3. // chain
  4. interface LoDashStatic {
  5. /**
  6. * Creates a lodash object that wraps value with explicit method chaining enabled.
  7. *
  8. * @param value The value to wrap.
  9. * @return Returns the new lodash wrapper instance.
  10. */
  11. chain<TrapAny extends { __lodashAnyHack: any }>(value: TrapAny): CollectionChain<any> & FunctionChain<any> & ObjectChain<any> & PrimitiveChain<any> & StringChain;
  12. /**
  13. * @see _.chain
  14. */
  15. chain<T extends null | undefined>(value: T): PrimitiveChain<T>;
  16. /**
  17. * @see _.chain
  18. */
  19. chain<T extends string>(value: T): StringChain<T>;
  20. /**
  21. * @see _.chain
  22. */
  23. chain(value: string | null | undefined): StringNullableChain;
  24. /**
  25. * @see _.chain
  26. */
  27. chain<T extends (...args: any[]) => any>(value: T): FunctionChain<T>;
  28. /**
  29. * @see _.chain
  30. */
  31. chain<T = any>(value: List<T> | null | undefined): CollectionChain<T>;
  32. /**
  33. * @see _.chain
  34. */
  35. chain<T extends object>(value: T | null | undefined): ObjectChain<T>;
  36. /**
  37. * @see _.chain
  38. */
  39. chain<T>(value: T): PrimitiveChain<T>;
  40. }
  41. interface Collection<T> {
  42. /**
  43. * @see _.chain
  44. */
  45. chain(): CollectionChain<T>;
  46. }
  47. interface String {
  48. /**
  49. * @see _.chain
  50. */
  51. chain<T extends string>(): StringChain<T>;
  52. }
  53. interface Object<T> {
  54. /**
  55. * @see _.chain
  56. */
  57. chain(): ObjectChain<T>;
  58. }
  59. interface Primitive<T> {
  60. /**
  61. * @see _.chain
  62. */
  63. chain(): PrimitiveChain<T>;
  64. }
  65. interface Function<T extends (...args: any) => any> {
  66. /**
  67. * @see _.chain
  68. */
  69. chain(): FunctionChain<T>;
  70. }
  71. interface LoDashExplicitWrapper<TValue> {
  72. /**
  73. * @see _.chain
  74. */
  75. chain(): this;
  76. }
  77. // prototype.commit
  78. interface LoDashImplicitWrapper<TValue> {
  79. /**
  80. * @see _.commit
  81. */
  82. commit(): this;
  83. }
  84. interface LoDashExplicitWrapper<TValue> {
  85. /**
  86. * @see _.commit
  87. */
  88. commit(): this;
  89. }
  90. // prototype.plant
  91. interface LoDashImplicitWrapper<TValue> {
  92. /**
  93. * @see _.plant
  94. */
  95. plant(value: unknown): this;
  96. }
  97. interface LoDashExplicitWrapper<TValue> {
  98. /**
  99. * @see _.plant
  100. */
  101. plant(value: unknown): this;
  102. }
  103. // prototype.reverse
  104. interface LoDashImplicitWrapper<TValue> {
  105. /**
  106. * @see _.reverse
  107. */
  108. reverse(): this;
  109. }
  110. interface LoDashExplicitWrapper<TValue> {
  111. /**
  112. * @see _.reverse
  113. */
  114. reverse(): this;
  115. }
  116. // prototype.toJSON
  117. interface LoDashImplicitWrapper<TValue> {
  118. /**
  119. * @see _.toJSON
  120. */
  121. toJSON(): TValue;
  122. }
  123. interface LoDashExplicitWrapper<TValue> {
  124. /**
  125. * @see _.toJSON
  126. */
  127. toJSON(): TValue;
  128. }
  129. // prototype.toString
  130. interface LoDashWrapper<TValue> {
  131. /**
  132. * @see _.toString
  133. */
  134. toString(): string;
  135. }
  136. // prototype.value
  137. interface LoDashImplicitWrapper<TValue> {
  138. /**
  139. * @see _.value
  140. */
  141. value(): TValue;
  142. }
  143. interface LoDashExplicitWrapper<TValue> {
  144. /**
  145. * @see _.value
  146. */
  147. value(): TValue;
  148. }
  149. // prototype.valueOf
  150. interface LoDashImplicitWrapper<TValue> {
  151. /**
  152. * @see _.valueOf
  153. */
  154. valueOf(): TValue;
  155. }
  156. interface LoDashExplicitWrapper<TValue> {
  157. /**
  158. * @see _.valueOf
  159. */
  160. valueOf(): TValue;
  161. }
  162. // tap
  163. interface LoDashStatic {
  164. /**
  165. * This method invokes interceptor and returns value. The interceptor is invoked with one
  166. * argument; (value). The purpose of this method is to "tap into" a method chain in order to perform operations
  167. * on intermediate results within the chain.
  168. *
  169. * @param value The value to provide to interceptor.
  170. * @param interceptor The function to invoke.
  171. * @return Returns value.
  172. */
  173. tap<T>(value: T, interceptor: (value: T) => void): T;
  174. }
  175. interface LoDashImplicitWrapper<TValue> {
  176. /**
  177. * @see _.tap
  178. */
  179. tap(interceptor: (value: TValue) => void): this;
  180. }
  181. interface LoDashExplicitWrapper<TValue> {
  182. /**
  183. * @see _.tap
  184. */
  185. tap(interceptor: (value: TValue) => void): this;
  186. }
  187. // thru
  188. interface LoDashStatic {
  189. /**
  190. * This method is like _.tap except that it returns the result of interceptor.
  191. *
  192. * @param value The value to provide to interceptor.
  193. * @param interceptor The function to invoke.
  194. * @return Returns the result of interceptor.
  195. */
  196. thru<T, TResult>(value: T, interceptor: (value: T) => TResult): TResult;
  197. }
  198. interface LoDashImplicitWrapper<TValue> {
  199. /**
  200. * @see _.thru
  201. */
  202. thru<TResult>(interceptor: (value: TValue) => TResult): ImpChain<TResult>;
  203. }
  204. interface LoDashExplicitWrapper<TValue> {
  205. /**
  206. * @see _.thru
  207. */
  208. thru<TResult>(interceptor: (value: TValue) => TResult): ExpChain<TResult>;
  209. }
  210. }