PageRenderTime 69ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 1ms

/src/Merchello.Web.UI/Scripts/typings/underscore/underscore.d.ts

https://github.com/vokseverk/Merchello
TypeScript Typings | 2979 lines | 653 code | 434 blank | 1892 comment | 3 complexity | f3cd66d81cfd9b30ae8e7a9563a7d932 MD5 | raw file
Possible License(s): MIT, CC-BY-SA-3.0
  1. // Type definitions for Underscore 1.5.2
  2. // Project: http://underscorejs.org/
  3. // Definitions by: Boris Yankov <https://github.com/borisyankov/>
  4. // Definitions by: Josh Baldwin <https://github.com/jbaldwin/>
  5. // Definitions: https://github.com/borisyankov/DefinitelyTyped
  6. declare module _ {
  7. /**
  8. * underscore.js _.throttle options.
  9. **/
  10. interface ThrottleSettings {
  11. /**
  12. * If you'd like to disable the leading-edge call, pass this as false.
  13. **/
  14. leading?: boolean;
  15. /**
  16. * If you'd like to disable the execution on the trailing-edge, pass false.
  17. **/
  18. trailing?: boolean;
  19. }
  20. /**
  21. * underscore.js template settings, set templateSettings or pass as an argument
  22. * to 'template()' to overide defaults.
  23. **/
  24. interface TemplateSettings {
  25. /**
  26. * Default value is '/<%([\s\S]+?)%>/g'.
  27. **/
  28. evaluate?: RegExp;
  29. /**
  30. * Default value is '/<%=([\s\S]+?)%>/g'.
  31. **/
  32. interpolate?: RegExp;
  33. /**
  34. * Default value is '/<%-([\s\S]+?)%>/g'.
  35. **/
  36. escape?: RegExp;
  37. }
  38. interface ListIterator<T, TResult> {
  39. (value: T, index: number, list: T[]): TResult;
  40. }
  41. interface ObjectIterator<T, TResult> {
  42. (element: T, key: string, list: any): TResult;
  43. }
  44. interface MemoIterator<T, TResult> {
  45. (prev: TResult, curr: T, index: number, list: T[]): TResult;
  46. }
  47. interface Collection<T> { }
  48. // Common interface between Arrays and jQuery objects
  49. interface List<T> extends Collection<T> {
  50. [index: number]: T;
  51. length: number;
  52. }
  53. interface Dictionary<T> extends Collection<T> {
  54. [index: string]: T;
  55. }
  56. }
  57. interface UnderscoreStatic {
  58. /**
  59. * Underscore OOP Wrapper, all Underscore functions that take an object
  60. * as the first parameter can be invoked through this function.
  61. * @param key First argument to Underscore object functions.
  62. **/
  63. <T>(value: Array<T>): Underscore<T>;
  64. <T>(value: T): Underscore<T>;
  65. /* *************
  66. * Collections *
  67. ************* */
  68. /**
  69. * Iterates over a list of elements, yielding each in turn to an iterator function. The iterator is
  70. * bound to the context object, if one is passed. Each invocation of iterator is called with three
  71. * arguments: (element, index, list). If list is a JavaScript object, iterator's arguments will be
  72. * (value, key, object). Delegates to the native forEach function if it exists.
  73. * @param list Iterates over this list of elements.
  74. * @param iterator Iterator function for each element `list`.
  75. * @param context 'this' object in `iterator`, optional.
  76. **/
  77. each<T>(
  78. list: _.List<T>,
  79. iterator: _.ListIterator<T, void>,
  80. context?: any): void;
  81. /**
  82. * @see _.each
  83. * @param object Iterators over this object's properties.
  84. * @param iterator Iterator function for each property on `obj`.
  85. * @param context 'this' object in `iterator`, optional.
  86. **/
  87. each<T>(
  88. object: _.Dictionary<T>,
  89. iterator: _.ObjectIterator<T, void>,
  90. context?: any): void;
  91. /**
  92. * @see _.each
  93. **/
  94. forEach<T>(
  95. list: _.List<T>,
  96. iterator: _.ListIterator<T, void >,
  97. context?: any): void;
  98. /**
  99. * @see _.each
  100. **/
  101. forEach<T>(
  102. object: _.Dictionary<T>,
  103. iterator: _.ObjectIterator<T, void >,
  104. context?: any): void;
  105. /**
  106. * Produces a new array of values by mapping each value in list through a transformation function
  107. * (iterator). If the native map method exists, it will be used instead. If list is a JavaScript
  108. * object, iterator's arguments will be (value, key, object).
  109. * @param list Maps the elements of this array.
  110. * @param iterator Map iterator function for each element in `list`.
  111. * @param context `this` object in `iterator`, optional.
  112. * @return The mapped array result.
  113. **/
  114. map<T, TResult>(
  115. list: _.List<T>,
  116. iterator: _.ListIterator<T, TResult>,
  117. context?: any): TResult[];
  118. /**
  119. * @see _.map
  120. * @param object Maps the properties of this object.
  121. * @param iterator Map iterator function for each property on `obj`.
  122. * @param context `this` object in `iterator`, optional.
  123. * @return The mapped object result.
  124. **/
  125. map<T, TResult>(
  126. object: _.Dictionary<T>,
  127. iterator: _.ObjectIterator<T, TResult>,
  128. context?: any): TResult[];
  129. /**
  130. * @see _.map
  131. **/
  132. collect<T, TResult>(
  133. list: _.List<T>, iterator:
  134. _.ListIterator<T, TResult>,
  135. context?: any): TResult[];
  136. /**
  137. * @see _.map
  138. **/
  139. collect<T, TResult>(
  140. object: _.Dictionary<T>,
  141. iterator: _.ObjectIterator<T, TResult>,
  142. context?: any): TResult[];
  143. /**
  144. * Also known as inject and foldl, reduce boils down a list of values into a single value.
  145. * Memo is the initial state of the reduction, and each successive step of it should be
  146. * returned by iterator. The iterator is passed four arguments: the memo, then the value
  147. * and index (or key) of the iteration, and finally a reference to the entire list.
  148. * @param list Reduces the elements of this array.
  149. * @param iterator Reduce iterator function for each element in `list`.
  150. * @param memo Initial reduce state.
  151. * @param context `this` object in `iterator`, optional.
  152. * @return Reduced object result.
  153. **/
  154. reduce<T, TResult>(
  155. list: _.Collection<T>,
  156. iterator: _.MemoIterator<T, TResult>,
  157. memo?: TResult,
  158. context?: any): TResult;
  159. /**
  160. * @see _.reduce
  161. **/
  162. inject<T, TResult>(
  163. list: _.Collection<T>,
  164. iterator: _.MemoIterator<T, TResult>,
  165. memo?: TResult,
  166. context?: any): TResult;
  167. /**
  168. * @see _.reduce
  169. **/
  170. foldl<T, TResult>(
  171. list: _.Collection<T>,
  172. iterator: _.MemoIterator<T, TResult>,
  173. memo?: TResult,
  174. context?: any): TResult;
  175. /**
  176. * The right-associative version of reduce. Delegates to the JavaScript 1.8 version of
  177. * reduceRight, if it exists. Foldr is not as useful in JavaScript as it would be in a
  178. * language with lazy evaluation.
  179. * @param list Reduces the elements of this array.
  180. * @param iterator Reduce iterator function for each element in `list`.
  181. * @param memo Initial reduce state.
  182. * @param context `this` object in `iterator`, optional.
  183. * @return Reduced object result.
  184. **/
  185. reduceRight<T, TResult>(
  186. list: _.Collection<T>,
  187. iterator: _.MemoIterator<T, TResult>,
  188. memo?: TResult,
  189. context?: any): TResult;
  190. /**
  191. * @see _.reduceRight
  192. **/
  193. foldr<T, TResult>(
  194. list: _.Collection<T>,
  195. iterator: _.MemoIterator<T, TResult>,
  196. memo?: TResult,
  197. context?: any): TResult;
  198. /**
  199. * Looks through each value in the list, returning the first one that passes a truth
  200. * test (iterator). The function returns as soon as it finds an acceptable element,
  201. * and doesn't traverse the entire list.
  202. * @param list Searches for a value in this list.
  203. * @param iterator Search iterator function for each element in `list`.
  204. * @param context `this` object in `iterator`, optional.
  205. * @return The first acceptable found element in `list`, if nothing is found undefined/null is returned.
  206. **/
  207. find<T>(
  208. list: _.Collection<T>,
  209. iterator: _.ListIterator<T, boolean>,
  210. context?: any): T;
  211. /**
  212. * @see _.find
  213. **/
  214. detect<T>(
  215. list: _.Collection<T>,
  216. iterator: _.ListIterator<T, boolean>,
  217. context?: any): T;
  218. /**
  219. * Looks through each value in the list, returning an array of all the values that pass a truth
  220. * test (iterator). Delegates to the native filter method, if it exists.
  221. * @param list Filter elements out of this list.
  222. * @param iterator Filter iterator function for each element in `list`.
  223. * @param context `this` object in `iterator`, optional.
  224. * @return The filtered list of elements.
  225. **/
  226. filter<T>(
  227. list: _.Collection<T>,
  228. iterator: _.ListIterator<T, boolean>,
  229. context?: any): T[];
  230. /**
  231. * @see _.filter
  232. **/
  233. select<T>(
  234. list: _.Collection<T>,
  235. iterator: _.ListIterator<T, boolean>,
  236. context?: any): T[];
  237. /**
  238. * Looks through each value in the list, returning an array of all the values that contain all
  239. * of the key-value pairs listed in properties.
  240. * @param list List to match elements again `properties`.
  241. * @param properties The properties to check for on each element within `list`.
  242. * @return The elements within `list` that contain the required `properties`.
  243. **/
  244. where<T, U extends {}>(
  245. list: _.Collection<T>,
  246. properties: U): T[];
  247. /**
  248. * Looks through the list and returns the first value that matches all of the key-value pairs listed in properties.
  249. * @param list Search through this list's elements for the first object with all `properties`.
  250. * @param properties Properties to look for on the elements within `list`.
  251. * @return The first element in `list` that has all `properties`.
  252. **/
  253. findWhere<T, U extends {}>(
  254. list: _.List<T>,
  255. properties: U): T;
  256. /**
  257. * Returns the values in list without the elements that the truth test (iterator) passes.
  258. * The opposite of filter.
  259. * Return all the elements for which a truth test fails.
  260. * @param list Reject elements within this list.
  261. * @param iterator Reject iterator function for each element in `list`.
  262. * @param context `this` object in `iterator`, optional.
  263. * @return The rejected list of elements.
  264. **/
  265. reject<T>(
  266. list: _.Collection<T>,
  267. iterator: _.ListIterator<T, boolean>,
  268. context?: any): T[];
  269. /**
  270. * Returns true if all of the values in the list pass the iterator truth test. Delegates to the
  271. * native method every, if present.
  272. * @param list Truth test against all elements within this list.
  273. * @param iterator Trust test iterator function for each element in `list`.
  274. * @param context `this` object in `iterator`, optional.
  275. * @return True if all elements passed the truth test, otherwise false.
  276. **/
  277. every<T>(
  278. list: _.Collection<T>,
  279. iterator?: _.ListIterator<T, boolean>,
  280. context?: any): boolean;
  281. /**
  282. * @see _.all
  283. **/
  284. all<T>(
  285. list: _.Collection<T>,
  286. iterator?: _.ListIterator<T, boolean>,
  287. context?: any): boolean;
  288. /**
  289. * Returns true if any of the values in the list pass the iterator truth test. Short-circuits and
  290. * stops traversing the list if a true element is found. Delegates to the native method some, if present.
  291. * @param list Truth test against all elements within this list.
  292. * @param iterator Trust test iterator function for each element in `list`.
  293. * @param context `this` object in `iterator`, optional.
  294. * @return True if any elements passed the truth test, otherwise false.
  295. **/
  296. any<T>(
  297. list: _.Collection<T>,
  298. iterator?: _.ListIterator<T, boolean>,
  299. context?: any): boolean;
  300. /**
  301. * @see _.any
  302. **/
  303. some<T>(
  304. list: _.Collection<T>,
  305. iterator?: _.ListIterator<T, boolean>,
  306. context?: any): boolean;
  307. /**
  308. * Returns true if the value is present in the list. Uses indexOf internally,
  309. * if list is an Array.
  310. * @param list Checks each element to see if `value` is present.
  311. * @param value The value to check for within `list`.
  312. * @return True if `value` is present in `list`, otherwise false.
  313. **/
  314. contains<T>(
  315. list: _.Collection<T>,
  316. value: T): boolean;
  317. /**
  318. * @see _.contains
  319. **/
  320. include<T>(
  321. list: _.Collection<T>,
  322. value: T): boolean;
  323. /**
  324. * Calls the method named by methodName on each value in the list. Any extra arguments passed to
  325. * invoke will be forwarded on to the method invocation.
  326. * @param list The element's in this list will each have the method `methodName` invoked.
  327. * @param methodName The method's name to call on each element within `list`.
  328. * @param arguments Additional arguments to pass to the method `methodName`.
  329. **/
  330. invoke<T extends {}>(
  331. list: _.Collection<T>,
  332. methodName: string,
  333. ...arguments: any[]): any;
  334. /**
  335. * A convenient version of what is perhaps the most common use-case for map: extracting a list of
  336. * property values.
  337. * @param list The list to pluck elements out of that have the property `propertyName`.
  338. * @param propertyName The property to look for on each element within `list`.
  339. * @return The list of elements within `list` that have the property `propertyName`.
  340. **/
  341. pluck<T extends {}>(
  342. list: _.Collection<T>,
  343. propertyName: string): any[];
  344. /**
  345. * Returns the maximum value in list.
  346. * @param list Finds the maximum value in this list.
  347. * @return Maximum value in `list`.
  348. **/
  349. max(list: _.List<number>): number;
  350. /**
  351. * Returns the maximum value in list. If iterator is passed, it will be used on each value to generate
  352. * the criterion by which the value is ranked.
  353. * @param list Finds the maximum value in this list.
  354. * @param iterator Compares each element in `list` to find the maximum value.
  355. * @param context `this` object in `iterator`, optional.
  356. * @return The maximum element within `list`.
  357. **/
  358. max<T>(
  359. list: _.Collection<T>,
  360. iterator?: _.ListIterator<T, any>,
  361. context?: any): T;
  362. /**
  363. * Returns the minimum value in list.
  364. * @param list Finds the minimum value in this list.
  365. * @return Minimum value in `list`.
  366. **/
  367. min(list: _.List<number>): number;
  368. /**
  369. * Returns the minimum value in list. If iterator is passed, it will be used on each value to generate
  370. * the criterion by which the value is ranked.
  371. * @param list Finds the minimum value in this list.
  372. * @param iterator Compares each element in `list` to find the minimum value.
  373. * @param context `this` object in `iterator`, optional.
  374. * @return The minimum element within `list`.
  375. **/
  376. min<T>(
  377. list: _.Collection<T>,
  378. iterator?: _.ListIterator<T, any>,
  379. context?: any): T;
  380. /**
  381. * Returns a sorted copy of list, ranked in ascending order by the results of running each value
  382. * through iterator. Iterator may also be the string name of the property to sort by (eg. length).
  383. * @param list Sorts this list.
  384. * @param iterator Sort iterator for each element within `list`.
  385. * @param context `this` object in `iterator`, optional.
  386. * @return A sorted copy of `list`.
  387. **/
  388. sortBy<T, TSort>(
  389. list: _.List<T>,
  390. iterator?: _.ListIterator<T, TSort>,
  391. context?: any): T[];
  392. /**
  393. * @see _.sortBy
  394. * @param iterator Sort iterator for each element within `list`.
  395. **/
  396. sortBy<T>(
  397. list: _.List<T>,
  398. iterator: string,
  399. context?: any): T[];
  400. /**
  401. * Splits a collection into sets, grouped by the result of running each value through iterator.
  402. * If iterator is a string instead of a function, groups by the property named by iterator on
  403. * each of the values.
  404. * @param list Groups this list.
  405. * @param iterator Group iterator for each element within `list`, return the key to group the element by.
  406. * @param context `this` object in `iterator`, optional.
  407. * @return An object with the group names as properties where each property contains the grouped elements from `list`.
  408. **/
  409. groupBy<T>(
  410. list: _.List<T>,
  411. iterator?: _.ListIterator<T, any>,
  412. context?: any): _.Dictionary<T[]>;
  413. /**
  414. * @see _.groupBy
  415. * @param iterator Property on each object to group them by.
  416. **/
  417. groupBy<T>(
  418. list: _.List<T>,
  419. iterator: string,
  420. context?: any): _.Dictionary<T[]>;
  421. /**
  422. * Given a `list`, and an `iterator` function that returns a key for each element in the list (or a property name),
  423. * returns an object with an index of each item. Just like _.groupBy, but for when you know your keys are unique.
  424. **/
  425. indexBy<T>(
  426. list: _.List<T>,
  427. iterator: _.ListIterator<T, any>,
  428. context?: any): _.Dictionary<T>;
  429. /**
  430. * @see _.indexBy
  431. * @param iterator Property on each object to index them by.
  432. **/
  433. indexBy<T>(
  434. list: _.List<T>,
  435. iterator: string,
  436. context?: any): _.Dictionary<T>;
  437. /**
  438. * Sorts a list into groups and returns a count for the number of objects in each group. Similar
  439. * to groupBy, but instead of returning a list of values, returns a count for the number of values
  440. * in that group.
  441. * @param list Group elements in this list and then count the number of elements in each group.
  442. * @param iterator Group iterator for each element within `list`, return the key to group the element by.
  443. * @param context `this` object in `iterator`, optional.
  444. * @return An object with the group names as properties where each property contains the number of elements in that group.
  445. **/
  446. countBy<T>(
  447. list: _.Collection<T>,
  448. iterator?: _.ListIterator<T, any>,
  449. context?: any): _.Dictionary<number[]>;
  450. /**
  451. * @see _.countBy
  452. * @param iterator Function name
  453. **/
  454. countBy<T>(
  455. list: _.Collection<T>,
  456. iterator: string,
  457. context?: any): _.Dictionary<number[]>;
  458. /**
  459. * Returns a shuffled copy of the list, using a version of the Fisher-Yates shuffle.
  460. * @param list List to shuffle.
  461. * @return Shuffled copy of `list`.
  462. **/
  463. shuffle<T>(list: _.Collection<T>): T[];
  464. /**
  465. * Produce a random sample from the `list`. Pass a number to return `n` random elements from the list. Otherwise a single random item will be returned.
  466. * @param list List to sample.
  467. * @return Random sample of `n` elements in `list`.
  468. **/
  469. sample<T>(list: _.Collection<T>, n: number): T[];
  470. /**
  471. * @see _.sample
  472. **/
  473. sample<T>(list: _.Collection<T>): T;
  474. /**
  475. * Converts the list (anything that can be iterated over), into a real Array. Useful for transmuting
  476. * the arguments object.
  477. * @param list object to transform into an array.
  478. * @return `list` as an array.
  479. **/
  480. toArray<T>(list: _.Collection<T>): T[];
  481. /**
  482. * Return the number of values in the list.
  483. * @param list Count the number of values/elements in this list.
  484. * @return Number of values in `list`.
  485. **/
  486. size<T>(list: _.Collection<T>): number;
  487. /*********
  488. * Arrays *
  489. **********/
  490. /**
  491. * Returns the first element of an array. Passing n will return the first n elements of the array.
  492. * @param array Retrieves the first element of this array.
  493. * @return Returns the first element of `array`.
  494. **/
  495. first<T>(array: _.List<T>): T;
  496. /**
  497. * @see _.first
  498. * @param n Return more than one element from `array`.
  499. **/
  500. first<T>(
  501. array: _.List<T>,
  502. n: number): T[];
  503. /**
  504. * @see _.first
  505. **/
  506. head<T>(array: _.List<T>): T;
  507. /**
  508. * @see _.first
  509. **/
  510. head<T>(
  511. array: _.List<T>,
  512. n: number): T[];
  513. /**
  514. * @see _.first
  515. **/
  516. take<T>(array: _.List<T>): T;
  517. /**
  518. * @see _.first
  519. **/
  520. take<T>(
  521. array: _.List<T>,
  522. n: number): T[];
  523. /**
  524. * Returns everything but the last entry of the array. Especially useful on the arguments object.
  525. * Pass n to exclude the last n elements from the result.
  526. * @param array Retreive all elements except the last `n`.
  527. * @param n Leaves this many elements behind, optional.
  528. * @return Returns everything but the last `n` elements of `array`.
  529. **/
  530. initial<T>(
  531. array: _.List<T>,
  532. n?: number): T[];
  533. /**
  534. * Returns the last element of an array. Passing n will return the last n elements of the array.
  535. * @param array Retrieves the last element of this array.
  536. * @return Returns the last element of `array`.
  537. **/
  538. last<T>(array: _.List<T>): T;
  539. /**
  540. * @see _.last
  541. * @param n Return more than one element from `array`.
  542. **/
  543. last<T>(
  544. array: _.List<T>,
  545. n: number): T[];
  546. /**
  547. * Returns the rest of the elements in an array. Pass an index to return the values of the array
  548. * from that index onward.
  549. * @param array The array to retrieve all but the first `index` elements.
  550. * @param n The index to start retrieving elements forward from, optional, default = 1.
  551. * @return Returns the elements of `array` from `index` to the end of `array`.
  552. **/
  553. rest<T>(
  554. array: _.List<T>,
  555. n?: number): T[];
  556. /**
  557. * @see _.rest
  558. **/
  559. tail<T>(
  560. array: _.List<T>,
  561. n?: number): T[];
  562. /**
  563. * @see _.rest
  564. **/
  565. drop<T>(
  566. array: _.List<T>,
  567. n?: number): T[];
  568. /**
  569. * Returns a copy of the array with all falsy values removed. In JavaScript, false, null, 0, "",
  570. * undefined and NaN are all falsy.
  571. * @param array Array to compact.
  572. * @return Copy of `array` without false values.
  573. **/
  574. compact<T>(array: _.List<T>): T[];
  575. /**
  576. * Flattens a nested array (the nesting can be to any depth). If you pass shallow, the array will
  577. * only be flattened a single level.
  578. * @param array The array to flatten.
  579. * @param shallow If true then only flatten one level, optional, default = false.
  580. * @return `array` flattened.
  581. **/
  582. flatten(
  583. array: _.List<any>,
  584. shallow?: boolean): any[];
  585. /**
  586. * Returns a copy of the array with all instances of the values removed.
  587. * @param array The array to remove `values` from.
  588. * @param values The values to remove from `array`.
  589. * @return Copy of `array` without `values`.
  590. **/
  591. without<T>(
  592. array: _.List<T>,
  593. ...values: T[]): T[];
  594. /**
  595. * Computes the union of the passed-in arrays: the list of unique items, in order, that are
  596. * present in one or more of the arrays.
  597. * @param arrays Array of arrays to compute the union of.
  598. * @return The union of elements within `arrays`.
  599. **/
  600. union<T>(...arrays: _.List<T>[]): T[];
  601. /**
  602. * Computes the list of values that are the intersection of all the arrays. Each value in the result
  603. * is present in each of the arrays.
  604. * @param arrays Array of arrays to compute the intersection of.
  605. * @return The intersection of elements within `arrays`.
  606. **/
  607. intersection<T>(...arrays: _.List<T>[]): T[];
  608. /**
  609. * Similar to without, but returns the values from array that are not present in the other arrays.
  610. * @param array Keeps values that are within `others`.
  611. * @param others The values to keep within `array`.
  612. * @return Copy of `array` with only `others` values.
  613. **/
  614. difference<T>(
  615. array: _.List<T>,
  616. ...others: _.List<T>[]): T[];
  617. /**
  618. * Produces a duplicate-free version of the array, using === to test object equality. If you know in
  619. * advance that the array is sorted, passing true for isSorted will run a much faster algorithm. If
  620. * you want to compute unique items based on a transformation, pass an iterator function.
  621. * @param array Array to remove duplicates from.
  622. * @param isSorted True if `array` is already sorted, optiona, default = false.
  623. * @param iterator Transform the elements of `array` before comparisons for uniqueness.
  624. * @param context 'this' object in `iterator`, optional.
  625. * @return Copy of `array` where all elements are unique.
  626. **/
  627. uniq<T, TSort>(
  628. array: _.List<T>,
  629. isSorted?: boolean,
  630. iterator?: _.ListIterator<T, TSort>,
  631. context?: any): T[];
  632. /**
  633. * @see _.uniq
  634. **/
  635. uniq<T, TSort>(
  636. array: _.List<T>,
  637. iterator?: _.ListIterator<T, TSort>,
  638. context?: any): T[];
  639. /**
  640. * @see _.uniq
  641. **/
  642. unique<T, TSort>(
  643. array: _.List<T>,
  644. iterator?: _.ListIterator<T, TSort>,
  645. context?: any): T[];
  646. /**
  647. * @see _.uniq
  648. **/
  649. unique<T, TSort>(
  650. array: _.List<T>,
  651. isSorted?: boolean,
  652. iterator?: _.ListIterator<T, TSort>,
  653. context?: any): T[];
  654. /**
  655. * Merges together the values of each of the arrays with the values at the corresponding position.
  656. * Useful when you have separate data sources that are coordinated through matching array indexes.
  657. * If you're working with a matrix of nested arrays, zip.apply can transpose the matrix in a similar fashion.
  658. * @param arrays The arrays to merge/zip.
  659. * @return Zipped version of `arrays`.
  660. **/
  661. zip(...arrays: any[][]): any[][];
  662. /**
  663. * @see _.zip
  664. **/
  665. zip(...arrays: any[]): any[];
  666. /**
  667. * Converts arrays into objects. Pass either a single list of [key, value] pairs, or a
  668. * list of keys, and a list of values.
  669. * @param keys Key array.
  670. * @param values Value array.
  671. * @return An object containing the `keys` as properties and `values` as the property values.
  672. **/
  673. object<TResult extends {}>(
  674. keys: _.List<string>,
  675. values: _.List<any>): TResult;
  676. /**
  677. * Converts arrays into objects. Pass either a single list of [key, value] pairs, or a
  678. * list of keys, and a list of values.
  679. * @param keyValuePairs Array of [key, value] pairs.
  680. * @return An object containing the `keys` as properties and `values` as the property values.
  681. **/
  682. object<TResult extends {}>(...keyValuePairs: any[][]): TResult;
  683. /**
  684. * @see _.object
  685. **/
  686. object<TResult extends {}>(
  687. list: _.List<any>,
  688. values?: any): TResult;
  689. /**
  690. * Returns the index at which value can be found in the array, or -1 if value is not present in the array.
  691. * Uses the native indexOf function unless it's missing. If you're working with a large array, and you know
  692. * that the array is already sorted, pass true for isSorted to use a faster binary search ... or, pass a number
  693. * as the third argument in order to look for the first matching value in the array after the given index.
  694. * @param array The array to search for the index of `value`.
  695. * @param value The value to search for within `array`.
  696. * @param isSorted True if the array is already sorted, optional, default = false.
  697. * @return The index of `value` within `array`.
  698. **/
  699. indexOf<T>(
  700. array: _.List<T>,
  701. value: T,
  702. isSorted?: boolean): number;
  703. /**
  704. * @see _indexof
  705. **/
  706. indexOf<T>(
  707. array: _.List<T>,
  708. value: T,
  709. startFrom: number): number;
  710. /**
  711. * Returns the index of the last occurrence of value in the array, or -1 if value is not present. Uses the
  712. * native lastIndexOf function if possible. Pass fromIndex to start your search at a given index.
  713. * @param array The array to search for the last index of `value`.
  714. * @param value The value to search for within `array`.
  715. * @param from The starting index for the search, optional.
  716. * @return The index of the last occurance of `value` within `array`.
  717. **/
  718. lastIndexOf<T>(
  719. array: _.List<T>,
  720. value: T,
  721. from?: number): number;
  722. /**
  723. * Uses a binary search to determine the index at which the value should be inserted into the list in order
  724. * to maintain the list's sorted order. If an iterator is passed, it will be used to compute the sort ranking
  725. * of each value, including the value you pass.
  726. * @param list The sorted list.
  727. * @param value The value to determine its index within `list`.
  728. * @param iterator Iterator to compute the sort ranking of each value, optional.
  729. * @return The index where `value` should be inserted into `list`.
  730. **/
  731. sortedIndex<T, TSort>(
  732. list: _.List<T>,
  733. value: T,
  734. iterator?: (x: T) => TSort, context?: any): number;
  735. /**
  736. * A function to create flexibly-numbered lists of integers, handy for each and map loops. start, if omitted,
  737. * defaults to 0; step defaults to 1. Returns a list of integers from start to stop, incremented (or decremented)
  738. * by step, exclusive.
  739. * @param start Start here.
  740. * @param stop Stop here.
  741. * @param step The number to count up by each iteration, optional, default = 1.
  742. * @return Array of numbers from `start` to `stop` with increments of `step`.
  743. **/
  744. range(
  745. start: number,
  746. stop: number,
  747. step?: number): number[];
  748. /**
  749. * @see _.range
  750. * @param stop Stop here.
  751. * @return Array of numbers from 0 to `stop` with increments of 1.
  752. * @note If start is not specified the implementation will never pull the step (step = arguments[2] || 0)
  753. **/
  754. range(stop: number): number[];
  755. /*************
  756. * Functions *
  757. *************/
  758. /**
  759. * Bind a function to an object, meaning that whenever the function is called, the value of this will
  760. * be the object. Optionally, bind arguments to the function to pre-fill them, also known as partial application.
  761. * @param func The function to bind `this` to `object`.
  762. * @param context The `this` pointer whenever `fn` is called.
  763. * @param arguments Additional arguments to pass to `fn` when called.
  764. * @return `fn` with `this` bound to `object`.
  765. **/
  766. bind(
  767. func: Function,
  768. context: any,
  769. ...arguments: any[]): () => any;
  770. /**
  771. * Binds a number of methods on the object, specified by methodNames, to be run in the context of that object
  772. * whenever they are invoked. Very handy for binding functions that are going to be used as event handlers,
  773. * which would otherwise be invoked with a fairly useless this. If no methodNames are provided, all of the
  774. * object's function properties will be bound to it.
  775. * @param object The object to bind the methods `methodName` to.
  776. * @param methodNames The methods to bind to `object`, optional and if not provided all of `object`'s
  777. * methods are bound.
  778. **/
  779. bindAll(
  780. object: any,
  781. ...methodNames: string[]): any;
  782. /**
  783. * Partially apply a function by filling in any number of its arguments, without changing its dynamic this value.
  784. * A close cousin of bind.
  785. * @param fn Function to partially fill in arguments.
  786. * @param arguments The partial arguments.
  787. * @return `fn` with partially filled in arguments.
  788. **/
  789. partial(
  790. fn: Function,
  791. ...arguments: any[]): Function;
  792. /**
  793. * Memoizes a given function by caching the computed result. Useful for speeding up slow-running computations.
  794. * If passed an optional hashFunction, it will be used to compute the hash key for storing the result, based
  795. * on the arguments to the original function. The default hashFunction just uses the first argument to the
  796. * memoized function as the key.
  797. * @param fn Computationally expensive function that will now memoized results.
  798. * @param hashFn Hash function for storing the result of `fn`.
  799. * @return Memoized version of `fn`.
  800. **/
  801. memoize(
  802. fn: Function,
  803. hashFn?: (...args: any[]) => string): Function;
  804. /**
  805. * Much like setTimeout, invokes function after wait milliseconds. If you pass the optional arguments,
  806. * they will be forwarded on to the function when it is invoked.
  807. * @param fn Function to delay `waitMS` amount of ms.
  808. * @param wait The amount of milliseconds to delay `fn`.
  809. * @arguments Additional arguments to pass to `fn`.
  810. **/
  811. delay(
  812. func: Function,
  813. wait: number,
  814. ...arguments: any[]): any;
  815. /**
  816. * @see _delay
  817. **/
  818. delay(
  819. func: Function,
  820. ...arguments: any[]): any;
  821. /**
  822. * Defers invoking the function until the current call stack has cleared, similar to using setTimeout
  823. * with a delay of 0. Useful for performing expensive computations or HTML rendering in chunks without
  824. * blocking the UI thread from updating. If you pass the optional arguments, they will be forwarded on
  825. * to the function when it is invoked.
  826. * @param fn The function to defer.
  827. * @param arguments Additional arguments to pass to `fn`.
  828. **/
  829. defer(
  830. fn: Function,
  831. ...arguments: any[]): void;
  832. /**
  833. * Creates and returns a new, throttled version of the passed function, that, when invoked repeatedly,
  834. * will only actually call the original function at most once per every wait milliseconds. Useful for
  835. * rate-limiting events that occur faster than you can keep up with.
  836. * By default, throttle will execute the function as soon as you call it for the first time, and,
  837. * if you call it again any number of times during the wait period, as soon as that period is over.
  838. * If you'd like to disable the leading-edge call, pass {leading: false}, and if you'd like to disable
  839. * the execution on the trailing-edge, pass {trailing: false}.
  840. * @param fn Function to throttle `waitMS` ms.
  841. * @param wait The number of milliseconds to wait before `fn` can be invoked again.
  842. * @param options Allows for disabling execution of the throttled function on either the leading or trailing edge.
  843. * @return `fn` with a throttle of `wait`.
  844. **/
  845. throttle(
  846. func: any,
  847. wait: number,
  848. options?: _.ThrottleSettings): Function;
  849. /**
  850. * Creates and returns a new debounced version of the passed function that will postpone its execution
  851. * until after wait milliseconds have elapsed since the last time it was invoked. Useful for implementing
  852. * behavior that should only happen after the input has stopped arriving. For example: rendering a preview
  853. * of a Markdown comment, recalculating a layout after the window has stopped being resized, and so on.
  854. *
  855. * Pass true for the immediate parameter to cause debounce to trigger the function on the leading instead
  856. * of the trailing edge of the wait interval. Useful in circumstances like preventing accidental double
  857. *-clicks on a "submit" button from firing a second time.
  858. * @param fn Function to debounce `waitMS` ms.
  859. * @param wait The number of milliseconds to wait before `fn` can be invoked again.
  860. * @param immediate True if `fn` should be invoked on the leading edge of `waitMS` instead of the trailing edge.
  861. * @return Debounced version of `fn` that waits `wait` ms when invoked.
  862. **/
  863. debounce(
  864. fn: Function,
  865. wait: number,
  866. immediate?: boolean): Function;
  867. /**
  868. * Creates a version of the function that can only be called one time. Repeated calls to the modified
  869. * function will have no effect, returning the value from the original call. Useful for initialization
  870. * functions, instead of having to set a boolean flag and then check it later.
  871. * @param fn Function to only execute once.
  872. * @return Copy of `fn` that can only be invoked once.
  873. **/
  874. once(fn: Function): Function;
  875. /**
  876. * Creates a version of the function that will only be run after first being called count times. Useful
  877. * for grouping asynchronous responses, where you want to be sure that all the async calls have finished,
  878. * before proceeding.
  879. * @param count Number of times to be called before actually executing.
  880. * @fn The function to defer execution `count` times.
  881. * @return Copy of `fn` that will not execute until it is invoked `count` times.
  882. **/
  883. after(
  884. count: number,
  885. fn: Function): Function;
  886. /**
  887. * Wraps the first function inside of the wrapper function, passing it as the first argument. This allows
  888. * the wrapper to execute code before and after the function runs, adjust the arguments, and execute it
  889. * conditionally.
  890. * @param fn Function to wrap.
  891. * @param wrapper The function that will wrap `fn`.
  892. * @return Wrapped version of `fn.
  893. **/
  894. wrap(
  895. fn: Function,
  896. wrapper: (fn: Function, ...args: any[]) => any): Function;
  897. /**
  898. * Returns the composition of a list of functions, where each function consumes the return value of the
  899. * function that follows. In math terms, composing the functions f(), g(), and h() produces f(g(h())).
  900. * @param functions List of functions to compose.
  901. * @return Composition of `functions`.
  902. **/
  903. compose(...functions: Function[]): Function;
  904. /**********
  905. * Objects *
  906. ***********/
  907. /**
  908. * Retrieve all the names of the object's properties.
  909. * @param object Retreive the key or property names from this object.
  910. * @return List of all the property names on `object`.
  911. **/
  912. keys(object: any): string[];
  913. /**
  914. * Return all of the values of the object's properties.
  915. * @param object Retreive the values of all the properties on this object.
  916. * @return List of all the values on `object`.
  917. **/
  918. values(object: any): any[];
  919. /**
  920. * Convert an object into a list of [key, value] pairs.
  921. * @param object Convert this object to a list of [key, value] pairs.
  922. * @return List of [key, value] pairs on `object`.
  923. **/
  924. pairs(object: any): any[][];
  925. /**
  926. * Returns a copy of the object where the keys have become the values and the values the keys.
  927. * For this to work, all of your object's values should be unique and string serializable.
  928. * @param object Object to invert key/value pairs.
  929. * @return An inverted key/value paired version of `object`.
  930. **/
  931. invert(object: any): any;
  932. /**
  933. * Returns a sorted list of the names of every method in an object - that is to say,
  934. * the name of every function property of the object.
  935. * @param object Object to pluck all function property names from.
  936. * @return List of all the function names on `object`.
  937. **/
  938. functions(object: any): string[];
  939. /**
  940. * @see _functions
  941. **/
  942. methods(object: any): string[];
  943. /**
  944. * Copy all of the properties in the source objects over to the destination object, and return
  945. * the destination object. It's in-order, so the last source will override properties of the
  946. * same name in previous arguments.
  947. * @param destination Object to extend all the properties from `sources`.
  948. * @param sources Extends `destination` with all properties from these source objects.
  949. * @return `destination` extended with all the properties from the `sources` objects.
  950. **/
  951. extend(
  952. destination: any,
  953. ...sources: any[]): any;
  954. /**
  955. * Return a copy of the object, filtered to only have values for the whitelisted keys
  956. * (or array of valid keys).
  957. * @param object Object to strip unwanted key/value pairs.
  958. * @keys The key/value pairs to keep on `object`.
  959. * @return Copy of `object` with only the `keys` properties.
  960. **/
  961. pick(
  962. object: any,
  963. ...keys: string[]): any;
  964. /**
  965. * Return a copy of the object, filtered to omit the blacklisted keys (or array of keys).
  966. * @param object Object to strip unwanted key/value pairs.
  967. * @param keys The key/value pairs to remove on `object`.
  968. * @return Copy of `object` without the `keys` properties.
  969. **/
  970. omit(
  971. object: any,
  972. ...keys: string[]): any;
  973. /**
  974. * @see _.omit
  975. **/
  976. omit(
  977. object: any,
  978. keys: string[]): any;
  979. /**
  980. * Fill in null and undefined properties in object with values from the defaults objects,
  981. * and return the object. As soon as the property is filled, further defaults will have no effect.
  982. * @param object Fill this object with default values.
  983. * @param defaults The default values to add to `object`.
  984. * @return `object` with added `defaults` values.
  985. **/
  986. defaults(
  987. object: any,
  988. ...defaults: any[]): any;
  989. /**
  990. * Create a shallow-copied clone of the object.
  991. * Any nested objects or arrays will be copied by reference, not duplicated.
  992. * @param object Object to clone.
  993. * @return Copy of `object`.
  994. **/
  995. clone<T>(object: T): T;
  996. /**
  997. * Invokes interceptor with the object, and then returns object. The primary purpose of this method
  998. * is to "tap into" a method chain, in order to perform operations on intermediate results within the chain.
  999. * @param object Argument to `interceptor`.
  1000. * @param intercepter The function to modify `object` before continuing the method chain.
  1001. * @return Modified `object`.
  1002. **/
  1003. tap<T>(object: T, intercepter: Function): T;
  1004. /**
  1005. * Does the object contain the given key? Identical to object.hasOwnProperty(key), but uses a safe
  1006. * reference to the hasOwnProperty function, in case it's been overridden accidentally.
  1007. * @param object Object to check for `key`.
  1008. * @param key The key to check for on `object`.
  1009. * @return True if `key` is a property on `object`, otherwise false.
  1010. **/
  1011. has(object: any, key: string): boolean;
  1012. /**
  1013. * Performs an optimized deep comparison between the two objects,
  1014. * to determine if they should be considered equal.
  1015. * @param object Compare to `other`.
  1016. * @param other Compare to `object`.
  1017. * @return True if `object` is equal to `other`.
  1018. **/
  1019. isEqual(object: any, other: any): boolean;
  1020. /**
  1021. * Returns true if object contains no values.
  1022. * @param object Check if this object has no properties or values.
  1023. * @return True if `object` is empty.
  1024. **/
  1025. isEmpty(object: any): boolean;
  1026. /**
  1027. * Returns true if object is a DOM element.
  1028. * @param object Check if this object is a DOM element.
  1029. * @return True if `object` is a DOM element, otherwise false.
  1030. **/
  1031. isElement(object: any): boolean;
  1032. /**
  1033. * Returns true if object is an Array.
  1034. * @param object Check if this object is an Array.
  1035. * @return True if `object` is an Array, otherwise false.
  1036. **/
  1037. isArray(object: any): boolean;
  1038. /**
  1039. * Returns true if value is an Object. Note that JavaScript arrays and functions are objects,
  1040. * while (normal) strings and numbers are not.
  1041. * @param object Check if this object is an Object.
  1042. * @return True of `object` is an Object, otherwise false.
  1043. **/
  1044. isObject(object: any): boolean;
  1045. /**
  1046. * Returns true if object is an Arguments object.
  1047. * @param object Check if this object is an Arguments object.
  1048. * @return True if `object` is an Arguments object, otherwise false.
  1049. **/
  1050. isArguments(object: any): boolean;
  1051. /**
  1052. * Returns true if object is a Function.
  1053. * @param object Check if this object is a Function.
  1054. * @return True if `object` is a Function, otherwise false.
  1055. **/
  1056. isFunction(object: any): boolean;
  1057. /**
  1058. * Returns true if object is a String.
  1059. * @param object Check if this object is a String.
  1060. * @return True if `object` is a String, otherwise false.
  1061. **/
  1062. isString(object: any): boolean;
  1063. /**
  1064. * Returns true if object is a Number (including NaN).
  1065. * @param object Check if this object is a Number.
  1066. * @return True if `object` is a Number, otherwise false.
  1067. **/
  1068. isNumber(object: any): boolean;
  1069. /**
  1070. * Returns true if object is a finite Number.
  1071. * @param object Check if this object is a finite Number.
  1072. * @return True if `object` is a finite Number.
  1073. **/
  1074. isFinite(object: any): boolean;
  1075. /**
  1076. * Returns true if object is either true or false.
  1077. * @param object Check if this object is a bool.
  1078. * @return True if `object` is a bool, otherwise false.
  1079. **/
  1080. isBoolean(object: any): boolean;
  1081. /**
  1082. * Returns true if object is a Date.
  1083. * @param object Check if this object is a Date.
  1084. * @return True if `object` is a Date, otherwise false.
  1085. **/
  1086. isDate(object: any): boolean;
  1087. /**
  1088. * Returns true if object is a RegExp.
  1089. * @param object Check if this object is a RegExp.
  1090. * @return True if `object` is a RegExp, otherwise false.
  1091. **/
  1092. isRegExp(object: any): boolean;
  1093. /**
  1094. * Returns true if object is NaN.
  1095. * Note: this is not the same as the native isNaN function,
  1096. * which will also return true if the variable is undefined.
  1097. * @param object Check if this object is NaN.
  1098. * @return True if `object` is NaN, otherwise false.
  1099. **/
  1100. isNaN(object: any): boolean;
  1101. /**
  1102. * Returns true if the value of object is null.
  1103. * @param object Check if this object is null.
  1104. * @return True if `object` is null, otherwise false.
  1105. **/
  1106. isNull(object: any): boolean;
  1107. /**
  1108. * Returns true if value is undefined.
  1109. * @param object Check if this object is undefined.
  1110. * @return True if `object` is undefined, otherwise false.
  1111. **/
  1112. isUndefined(value: any): boolean;
  1113. /* *********
  1114. * Utility *
  1115. ********** */
  1116. /**
  1117. * Give control of the "_" variable back to its previous owner.
  1118. * Returns a reference to the Underscore object.
  1119. * @return Underscore object reference.
  1120. **/
  1121. noConflict(): any;
  1122. /**
  1123. * Returns the same value that is used as the argument. In math: f(x) = x
  1124. * This function looks useless, but is used throughout Underscore as a default iterator.
  1125. * @param value Identity of this object.
  1126. * @return `value`.
  1127. **/
  1128. identity<T>(value: T): T;
  1129. /**
  1130. * Invokes the given iterator function n times.
  1131. * Each invocation of iterator is called with an index argument
  1132. * @param n Number of times to invoke `iterator`.
  1133. * @param iterator Function iterator to invoke `n` times.
  1134. * @param context `this` object in `iterator`, optional.
  1135. **/
  1136. times<TResult>(n: number, iterator: (n: number) => TResult, context?: any): TResult[];
  1137. /**
  1138. * Returns a random integer between min and max, inclusive. If you only pass one argument,
  1139. * it will return a number between 0 and that number.
  1140. * @param max The maximum random number.
  1141. * @return A random number between 0 and `max`.
  1142. **/
  1143. random(max: number): number;
  1144. /**
  1145. * @see _.random
  1146. * @param min The minimum random number.
  1147. * @return A random number between `min` and `max`.
  1148. **/
  1149. random(min: number, max: number): number;
  1150. /**
  1151. * Allows you to extend Underscore with your own utility functions. Pass a hash of
  1152. * {name: function} definitions to have your functions added to the Underscore object,
  1153. * as well as the OOP wrapper.
  1154. * @param object Mixin object containing key/function pairs to add to the Underscore object.
  1155. **/
  1156. mixin(object: any): void;
  1157. /**
  1158. * Generate a globally-unique id for client-side models or DOM elements that need one.
  1159. * If prefix is passed, the id will be appended to it. Without prefix, returns an integer.
  1160. * @param prefix A prefix string to start the unique ID with.
  1161. * @return Unique string ID beginning with `prefix`.
  1162. **/
  1163. uniqueId(prefix: string): string;
  1164. /**
  1165. * @see _.uniqueId
  1166. **/
  1167. uniqueId(): number;
  1168. /**
  1169. * Escapes a string for insertion into HTML, replacing &, <, >, ", ', and / characters.
  1170. * @param str Raw string to escape.
  1171. * @return `str` HTML escaped.
  1172. **/
  1173. escape(str: string): string;
  1174. /**
  1175. * If the value of the named property is a function then invoke it; otherwise, return it.
  1176. * @param object Object to maybe invoke function `property` on.
  1177. * @param property The function by name to invoke on `object`.
  1178. * @return The result of invoking the function `property` on `object.
  1179. **/
  1180. result(object: any, property: string): any;
  1181. /**
  1182. * Compiles JavaScript templates into functions that can be evaluated for rendering. Useful
  1183. * for rendering complicated bits of HTML from JSON data sources. Template functions can both
  1184. * interpolate variables, using <%= ... %>, as well as execute arbitrary JavaScript code, with
  1185. * <% ... %>. If you wish to interpolate a value, and have it be HTML-escaped, use <%- ... %> When
  1186. * you evaluate a template function, pass in a data object that has properties corresponding to
  1187. * the template's free variables. If you're writing a one-off, you can pass the data object as
  1188. * the second parameter to template in order to render immediately instead of returning a template
  1189. * function. The settings argument should be a hash containing any _.templateSettings that should
  1190. * be overridden.
  1191. * @param templateString Underscore HTML template.
  1192. * @param data Data to use when compiling `templateString`.
  1193. * @param settings Settings to use while compiling.
  1194. * @return Returns the compiled Underscore HTML template.
  1195. **/
  1196. template(templateString: string, data?: any, settings?: _.TemplateSettings): (...data: any[]) => string;
  1197. /**
  1198. * By default, Underscore uses ERB-style template delimiters, change the
  1199. * following template settings to use alternative delimiters.
  1200. **/
  1201. templateSettings: _.TemplateSettings;
  1202. /* **********
  1203. * Chaining *
  1204. *********** */
  1205. /**
  1206. * Returns a wrapped object. Calling methods on this object will continue to return wrapped objects
  1207. * until value() is used.
  1208. * @param obj Object to chain.
  1209. * @return Wrapped `obj`.
  1210. **/
  1211. chain<T>(obj: T[]): _Chain<T>;
  1212. chain<T extends {}>(obj: T): _Chain<T>;
  1213. /**
  1214. * Extracts the value of a wrapped object.
  1215. * @param obj Wrapped object to extract the value from.
  1216. * @return Value of `obj`.
  1217. **/
  1218. value<T, TResult>(obj: T): TResult;
  1219. }
  1220. interface Underscore<T> {
  1221. /* *************
  1222. * Collections *
  1223. ************* */
  1224. /**
  1225. * Wrapped type `any[]`.
  1226. * @see _.each
  1227. **/
  1228. each(iterator: _.ListIterator<T, void>, context?: any): void;
  1229. /**
  1230. * @see _.each
  1231. **/
  1232. each(iterator: _.ObjectIterator<T, void>, context?: any): void;
  1233. /**
  1234. * @see _.each
  1235. **/
  1236. forEach(iterator: _.ListIterator<T, void>, context?: any): void;
  1237. /**
  1238. * @see _.each
  1239. **/
  1240. forEach(iterator: _.ObjectIterator<T, void>, context?: any): void;
  1241. /**
  1242. * Wrapped type `any[]`.
  1243. * @see _.map
  1244. **/
  1245. map<TResult>(iterator: _.ListIterator<T, TResult>, context?: any): TResult[];
  1246. /**
  1247. * Wrapped type `any[]`.
  1248. * @see _.map
  1249. **/
  1250. map<TResult>(iterator: _.ObjectIterator<T, TResult>, context?: any): TResult[];
  1251. /**
  1252. * @see _.map
  1253. **/
  1254. collect<TResult>(iterator: _.ListIterator<T, TResult>, context?: any): TResult[];
  1255. /**
  1256. * @see _.map
  1257. **/
  1258. collect<TResult>(iterator: _.ObjectIterator<T, TResult>, context?: any): TResult[];
  1259. /**
  1260. * Wrapped type `any[]`.
  1261. * @see _.reduce
  1262. **/
  1263. reduce<TResult>(iterator: _.MemoIterator<T, TResult>, memo?: TResult, context?: any): TResult;
  1264. /**
  1265. * @see _.reduce
  1266. **/
  1267. inject<TResult>(iterator: _.MemoIterator<T, TResult>, memo?: TResult, context?: any): TResult;
  1268. /**
  1269. * @see _.reduce
  1270. **/
  1271. foldl<TResult>(iterator: _.MemoIterator<T, TResult>, memo?: TResult, context?: any): TResult;
  1272. /**
  1273. * Wrapped type `any[]`.
  1274. * @see _.reduceRight
  1275. **/
  1276. reduceRight<TResult>(iterator: _.MemoIterator<T, TResult>, memo?: TResult, context?: any): TResult;
  1277. /**
  1278. * @see _.reduceRight
  1279. **/
  1280. foldr<TResult>(iterator: _.MemoIterator<T, TResult>, memo?: TResult, context?: any): TResult;
  1281. /**
  1282. * Wrapped type `any[]`.
  1283. * @see _.find
  1284. **/
  1285. find(iterator: _.ListIterator<T, boolean>, context?: any): T;
  1286. /**
  1287. * @see _.find
  1288. **/
  1289. detect(iterator: _.ListIterator<T, boolean>, context?: any): T;
  1290. /**
  1291. * Wrapped type `any[]`.
  1292. * @see _.filter
  1293. **/
  1294. filter(iterator: _.ListIterator<T, boolean>, context?: any): T[];
  1295. /**
  1296. * @see _.filter
  1297. **/
  1298. select(iterator: _.ListIterator<T, boolean>, context?: any): T[];
  1299. /**
  1300. * Wrapped type `any[]`.
  1301. * @see _.where
  1302. **/
  1303. where<U extends {}>(properties: U): T[];
  1304. /**
  1305. * Wrapped type `any[]`.
  1306. * @see _.findWhere
  1307. **/
  1308. findWhere<U extends {}>(properties: U): T;
  1309. /**
  1310. * Wrapped type `any[]`.
  1311. * @see _.reject
  1312. **/
  1313. reject(iterator: _.ListIterator<T, boolean>, context?: any): T[];
  1314. /**
  1315. * Wrapped type `any[]`.
  1316. * @see _.all
  1317. **/
  1318. all(iterator?: _.ListIterator<T, boolean>, context?: any): boolean;
  1319. /**
  1320. * @see _.all
  1321. **/
  1322. every(iterator?: _.ListIterator<T, boolean>, context?: any): boolean;
  1323. /**
  1324. * Wrapped type `any[]`.
  1325. * @see _.any
  1326. **/
  1327. any(iterator?: _.ListIterator<T, boolean>, context?: any): boolean;
  1328. /**
  1329. * @see _.any
  1330. **/
  1331. some(iterator?: _.ListIterator<T, boolean>, context?: any): boolean;
  1332. /**
  1333. * Wrapped type `any[]`.
  1334. * @see _.contains
  1335. **/
  1336. contains(value: T): boolean;
  1337. /**
  1338. * Alias for 'contains'.
  1339. * @see contains
  1340. **/
  1341. include(value: T): boolean;
  1342. /**
  1343. * Wrapped type `any[]`.
  1344. * @see _.invoke
  1345. **/
  1346. invoke(methodName: string, ...arguments: any[]): any;
  1347. /**
  1348. * Wrapped type `any[]`.
  1349. * @see _.pluck
  1350. **/
  1351. pluck(propertyName: string): any[];
  1352. /**
  1353. * Wrapped type `number[]`.
  1354. * @see _.max
  1355. **/
  1356. max(): number;
  1357. /**
  1358. * Wrapped type `any[]`.
  1359. * @see _.max
  1360. **/
  1361. max(iterator: _.ListIterator<T, number>, context?: any): T;
  1362. /**
  1363. * Wrapped type `any[]`.
  1364. * @see _.max
  1365. **/
  1366. max(iterator?: _.ListIterator<T, any>, context?: any): T;
  1367. /**
  1368. * Wrapped type `number[]`.
  1369. * @see _.min
  1370. **/
  1371. min(): number;
  1372. /**
  1373. * Wrapped type `any[]`.
  1374. * @see _.min
  1375. **/
  1376. min(iterator: _.ListIterator<T, number>, context?: any): T;
  1377. /**
  1378. * Wrapped type `any[]`.
  1379. * @see _.min
  1380. **/
  1381. min(iterator?: _.ListIterator<T, any>, context?: any): T;
  1382. /**
  1383. * Wrapped type `any[]`.
  1384. * @see _.sortBy
  1385. **/
  1386. sortBy(iterator?: _.ListIterator<T, any>, context?: any): T[];
  1387. /**
  1388. * Wrapped type `any[]`.
  1389. * @see _.sortBy
  1390. **/
  1391. sortBy(iterator: string, context?: any): T[];
  1392. /**
  1393. * Wrapped type `any[]`.
  1394. * @see _.groupBy
  1395. **/
  1396. groupBy(iterator?: _.ListIterator<T, any>, context?: any): _.Dictionary<_.List<T>>;
  1397. /**
  1398. * Wrapped type `any[]`.
  1399. * @see _.groupBy
  1400. **/
  1401. groupBy(iterator: string, context?: any): _.Dictionary<T[]>;
  1402. /**
  1403. * Wrapped type `any[]`.
  1404. * @see _.indexBy
  1405. **/
  1406. indexBy(iterator: _.ListIterator<T, any>, context?: any): _.Dictionary<T>;
  1407. /**
  1408. * Wrapped type `any[]`.
  1409. * @see _.indexBy
  1410. **/
  1411. indexBy(iterator: string, context?: any): _.Dictionary<T>;
  1412. /**
  1413. * Wrapped type `any[]`.
  1414. * @see _.countBy
  1415. **/
  1416. countBy(iterator?: _.ListIterator<T, any>, context?: any): _.Dictionary<number[]>;
  1417. /**
  1418. * Wrapped type `any[]`.
  1419. * @see _.countBy
  1420. **/
  1421. countBy(iterator: string, context?: any): _.Dictionary<number[]>;
  1422. /**
  1423. * Wrapped type `any[]`.
  1424. * @see _.shuffle
  1425. **/
  1426. shuffle(): T[];
  1427. /**
  1428. * Wrapped type `any[]`.
  1429. * @see _.sample
  1430. **/
  1431. sample<T>(n: number): T[];
  1432. /**
  1433. * @see _.sample
  1434. **/
  1435. sample<T>(): T;
  1436. /**
  1437. * Wrapped type `any`.
  1438. * @see _.toArray
  1439. **/
  1440. toArray(): T[];
  1441. /**
  1442. * Wrapped type `any`.
  1443. * @see _.size
  1444. **/
  1445. size(): number;
  1446. /*********
  1447. * Arrays *
  1448. **********/
  1449. /**
  1450. * Wrapped type `any[]`.
  1451. * @see _.first
  1452. **/
  1453. first(): T;
  1454. /**
  1455. * Wrapped type `any[]`.
  1456. * @see _.first
  1457. **/
  1458. first(n: number): T[];
  1459. /**
  1460. * @see _.first
  1461. **/
  1462. head(): T;
  1463. /**
  1464. * @see _.first
  1465. **/
  1466. head(n: number): T[];
  1467. /**
  1468. * @see _.first
  1469. **/
  1470. take(): T;
  1471. /**
  1472. * @see _.first
  1473. **/
  1474. take(n: number): T[];
  1475. /**
  1476. * Wrapped type `any[]`.
  1477. * @see _.initial
  1478. **/
  1479. initial(n?: number): T[];
  1480. /**
  1481. * Wrapped type `any[]`.
  1482. * @see _.last
  1483. **/
  1484. last(): T;
  1485. /**
  1486. * Wrapped type `any[]`.
  1487. * @see _.last
  1488. **/
  1489. last(n: number): T[];
  1490. /**
  1491. * Wrapped type `any[]`.
  1492. * @see _.rest
  1493. **/
  1494. rest(n?: number): T[];
  1495. /**
  1496. * @see _.rest
  1497. **/
  1498. tail(n?: number): T[];
  1499. /**
  1500. * @see _.rest
  1501. **/
  1502. drop(n?: number): T[];
  1503. /**
  1504. * Wrapped type `any[]`.
  1505. * @see _.compact
  1506. **/
  1507. compact(): T[];
  1508. /**
  1509. * Wrapped type `any`.
  1510. * @see _.flatten
  1511. **/
  1512. flatten(shallow?: boolean): any[];
  1513. /**
  1514. * Wrapped type `any[]`.
  1515. * @see _.without
  1516. **/
  1517. without(...values: T[]): T[];
  1518. /**
  1519. * Wrapped type `any[][]`.
  1520. * @see _.union
  1521. **/
  1522. union(...arrays: _.List<T>[]): T[];
  1523. /**
  1524. * Wrapped type `any[][]`.
  1525. * @see _.intersection
  1526. **/
  1527. intersection(...arrays: _.List<T>[]): T[];
  1528. /**
  1529. * Wrapped type `any[]`.
  1530. * @see _.difference
  1531. **/
  1532. difference(...others: _.List<T>[]): T[];
  1533. /**
  1534. * Wrapped type `any[]`.
  1535. * @see _.uniq
  1536. **/
  1537. uniq(isSorted?: boolean, iterator?: _.ListIterator<T, any>): T[];
  1538. /**
  1539. * Wrapped type `any[]`.
  1540. * @see _.uniq
  1541. **/
  1542. uniq<TSort>(iterator?: _.ListIterator<T, TSort>, context?: any): T[];
  1543. /**
  1544. * @see _.uniq
  1545. **/
  1546. unique<TSort>(isSorted?: boolean, iterator?: _.ListIterator<T, TSort>): T[];
  1547. /**
  1548. * @see _.uniq
  1549. **/
  1550. unique<TSort>(iterator?: _.ListIterator<T, TSort>, context?: any): T[];
  1551. /**
  1552. * Wrapped type `any[][]`.
  1553. * @see _.zip
  1554. **/
  1555. zip(...arrays: any[][]): any[][];
  1556. /**
  1557. * Wrapped type `any[][]`.
  1558. * @see _.object
  1559. **/
  1560. object(...keyValuePairs: any[][]): any;
  1561. /**
  1562. * @see _.object
  1563. **/
  1564. object(values?: any): any;
  1565. /**
  1566. * Wrapped type `any[]`.
  1567. * @see _.indexOf
  1568. **/
  1569. indexOf(value: T, isSorted?: boolean): number;
  1570. /**
  1571. * @see _.indexOf
  1572. **/
  1573. indexOf(value: T, startFrom: number): number;
  1574. /**
  1575. * Wrapped type `any[]`.
  1576. * @see _.lastIndexOf
  1577. **/
  1578. lastIndexOf(value: T, from?: number): number;
  1579. /**
  1580. * Wrapped type `any[]`.
  1581. * @see _.sortedIndex
  1582. **/
  1583. sortedIndex(value: T, iterator?: (x: T) => any, context?: any): number;
  1584. /**
  1585. * Wrapped type `number`.
  1586. * @see _.range
  1587. **/
  1588. range(stop: number, step?: number): number[];
  1589. /**
  1590. * Wrapped type `number`.
  1591. * @see _.range
  1592. **/
  1593. range(): number[];
  1594. /* ***********
  1595. * Functions *
  1596. ************ */
  1597. /**
  1598. * Wrapped type `Function`.
  1599. * @see _.bind
  1600. **/
  1601. bind(object: any, ...arguments: any[]): Function;
  1602. /**
  1603. * Wrapped type `object`.
  1604. * @see _.bindAll
  1605. **/
  1606. bindAll(...methodNames: string[]): any;
  1607. /**
  1608. * Wrapped type `Function`.
  1609. * @see _.partial
  1610. **/
  1611. partial(...arguments: any[]): Function;
  1612. /**
  1613. * Wrapped type `Function`.
  1614. * @see _.memoize
  1615. **/
  1616. memoize(hashFn?: (n: any) => string): Function;
  1617. /**
  1618. * Wrapped type `Function`.
  1619. * @see _.defer
  1620. **/
  1621. defer(...arguments: any[]): void;
  1622. /**
  1623. * Wrapped type `Function`.
  1624. * @see _.delay
  1625. **/
  1626. delay(wait: number, ...arguments: any[]): any;
  1627. /**
  1628. * @see _.delay
  1629. **/
  1630. delay(...arguments: any[]): any;
  1631. /**
  1632. * Wrapped type `Function`.
  1633. * @see _.throttle
  1634. **/
  1635. throttle(wait: number, options?: _.ThrottleSettings): Function;
  1636. /**
  1637. * Wrapped type `Function`.
  1638. * @see _.debounce
  1639. **/
  1640. debounce(wait: number, immediate?: boolean): Function;
  1641. /**
  1642. * Wrapped type `Function`.
  1643. * @see _.once
  1644. **/
  1645. once(): Function;
  1646. /**
  1647. * Wrapped type `number`.
  1648. * @see _.after
  1649. **/
  1650. after(func: Function): Function;
  1651. /**
  1652. * Wrapped type `Function`.
  1653. * @see _.wrap
  1654. **/
  1655. wrap(wrapper: Function): () => Function;
  1656. /**
  1657. * Wrapped type `Function[]`.
  1658. * @see _.compose
  1659. **/
  1660. compose(...functions: Function[]): Function;
  1661. /********* *
  1662. * Objects *
  1663. ********** */
  1664. /**
  1665. * Wrapped type `object`.
  1666. * @see _.keys
  1667. **/
  1668. keys(): string[];
  1669. /**
  1670. * Wrapped type `object`.
  1671. * @see _.values
  1672. **/
  1673. values(): T[];
  1674. /**
  1675. * Wrapped type `object`.
  1676. * @see _.pairs
  1677. **/
  1678. pairs(): any[][];
  1679. /**
  1680. * Wrapped type `object`.
  1681. * @see _.invert
  1682. **/
  1683. invert(): any;
  1684. /**
  1685. * Wrapped type `object`.
  1686. * @see _.functions
  1687. **/
  1688. functions(): string[];
  1689. /**
  1690. * @see _.functions
  1691. **/
  1692. methods(): string[];
  1693. /**
  1694. * Wrapped type `object`.
  1695. * @see _.extend
  1696. **/
  1697. extend(...sources: any[]): any;
  1698. /**
  1699. * Wrapped type `object`.
  1700. * @see _.pick
  1701. **/
  1702. pick(...keys: string[]): any;
  1703. pick(keys: string[]): any;
  1704. /**
  1705. * Wrapped type `object`.
  1706. * @see _.omit
  1707. **/
  1708. omit(...keys: string[]): any;
  1709. omit(keys: string[]): any;
  1710. /**
  1711. * Wrapped type `object`.
  1712. * @see _.defaults
  1713. **/
  1714. defaults(...defaults: any[]): any;
  1715. /**
  1716. * Wrapped type `any[]`.
  1717. * @see _.clone
  1718. **/
  1719. clone(): T;
  1720. /**
  1721. * Wrapped type `object`.
  1722. * @see _.tap
  1723. **/
  1724. tap(interceptor: (...as: any[]) => any): any;
  1725. /**
  1726. * Wrapped type `object`.
  1727. * @see _.has
  1728. **/
  1729. has(key: string): boolean;
  1730. /**
  1731. * Wrapped type `object`.
  1732. * @see _.isEqual
  1733. **/
  1734. isEqual(other: any): boolean;
  1735. /**
  1736. * Wrapped type `object`.
  1737. * @see _.isEmpty
  1738. **/
  1739. isEmpty(): boolean;
  1740. /**
  1741. * Wrapped type `object`.
  1742. * @see _.isElement
  1743. **/
  1744. isElement(): boolean;
  1745. /**
  1746. * Wrapped type `object`.
  1747. * @see _.isArray
  1748. **/
  1749. isArray(): boolean;
  1750. /**
  1751. * Wrapped type `object`.
  1752. * @see _.isObject
  1753. **/
  1754. isObject(): boolean;
  1755. /**
  1756. * Wrapped type `object`.
  1757. * @see _.isArguments
  1758. **/
  1759. isArguments(): boolean;
  1760. /**
  1761. * Wrapped type `object`.
  1762. * @see _.isFunction
  1763. **/
  1764. isFunction(): boolean;
  1765. /**
  1766. * Wrapped type `object`.
  1767. * @see _.isString
  1768. **/
  1769. isString(): boolean;
  1770. /**
  1771. * Wrapped type `object`.
  1772. * @see _.isNumber
  1773. **/
  1774. isNumber(): boolean;
  1775. /**
  1776. * Wrapped type `object`.
  1777. * @see _.isFinite
  1778. **/
  1779. isFinite(): boolean;
  1780. /**
  1781. * Wrapped type `object`.
  1782. * @see _.isBoolean
  1783. **/
  1784. isBoolean(): boolean;
  1785. /**
  1786. * Wrapped type `object`.
  1787. * @see _.isDate
  1788. **/
  1789. isDate(): boolean;
  1790. /**
  1791. * Wrapped type `object`.
  1792. * @see _.isRegExp
  1793. **/
  1794. isRegExp(): boolean;
  1795. /**
  1796. * Wrapped type `object`.
  1797. * @see _.isNaN
  1798. **/
  1799. isNaN(): boolean;
  1800. /**
  1801. * Wrapped type `object`.
  1802. * @see _.isNull
  1803. **/
  1804. isNull(): boolean;
  1805. /**
  1806. * Wrapped type `object`.
  1807. * @see _.isUndefined
  1808. **/
  1809. isUndefined(): boolean;
  1810. /********* *
  1811. * Utility *
  1812. ********** */
  1813. /**
  1814. * Wrapped type `any`.
  1815. * @see _.identity
  1816. **/
  1817. identity(): any;
  1818. /**
  1819. * Wrapped type `number`.
  1820. * @see _.times
  1821. **/
  1822. times<TResult>(iterator: (n: number) => TResult, context?: any): TResult[];
  1823. /**
  1824. * Wrapped type `number`.
  1825. * @see _.random
  1826. **/
  1827. random(): number;
  1828. /**
  1829. * Wrapped type `number`.
  1830. * @see _.random
  1831. **/
  1832. random(max: number): number;
  1833. /**
  1834. * Wrapped type `object`.
  1835. * @see _.mixin
  1836. **/
  1837. mixin(): void;
  1838. /**
  1839. * Wrapped type `string`.
  1840. * @see _.uniqueId
  1841. **/
  1842. uniqueId(): string;
  1843. /**
  1844. * Wrapped type `string`.
  1845. * @see _.escape
  1846. **/
  1847. escape(): string;
  1848. /**
  1849. * Wrapped type `object`.
  1850. * @see _.result
  1851. **/
  1852. result(property: string): any;
  1853. /**
  1854. * Wrapped type `string`.
  1855. * @see _.template
  1856. **/
  1857. template(data?: any, settings?: _.TemplateSettings): (...data: any[]) => string;
  1858. /********** *
  1859. * Chaining *
  1860. *********** */
  1861. /**
  1862. * Wrapped type `any`.
  1863. * @see _.chain
  1864. **/
  1865. chain(): _Chain<T>;
  1866. /**
  1867. * Wrapped type `any`.
  1868. * @see _.value
  1869. **/
  1870. value<TResult>(): TResult;
  1871. }
  1872. interface _Chain<T> {
  1873. /* *************
  1874. * Collections *
  1875. ************* */
  1876. /**
  1877. * Wrapped type `any[]`.
  1878. * @see _.each
  1879. **/
  1880. each(iterator: _.ListIterator<T, void >, context?: any): _Chain<T>;
  1881. /**
  1882. * @see _.each
  1883. **/
  1884. each(iterator: _.ObjectIterator<T, void >, context?: any): _Chain<T>;
  1885. /**
  1886. * @see _.each
  1887. **/
  1888. forEach(iterator: _.ListIterator<T, void >, context?: any): _Chain<T>;
  1889. /**
  1890. * @see _.each
  1891. **/
  1892. forEach(iterator: _.ObjectIterator<T, void >, context?: any): _Chain<T>;
  1893. /**
  1894. * Wrapped type `any[]`.
  1895. * @see _.map
  1896. **/
  1897. map<TArray>(iterator: (value: T, index: number, list: T[]) => TArray[], context?: any): _ChainOfArrays<TArray>;
  1898. //Not sure why this won't work, might be a TypeScript error?
  1899. //map<TArray>(iterator: _.ListIterator<T, TArray[]>, context?: any): _ChainOfArrays<TArray>;
  1900. /**
  1901. * Wrapped type `any[]`.
  1902. * @see _.map
  1903. **/
  1904. map<TResult>(iterator: _.ListIterator<T, TResult>, context?: any): _Chain<TResult>;
  1905. /**
  1906. * Wrapped type `any[]`.
  1907. * @see _.map
  1908. **/
  1909. map<TArray>(iterator: (element: T, key: string, list: any) => TArray[], context?: any): _ChainOfArrays<TArray>;
  1910. //Not sure why this won't work, might be a TypeScript error?
  1911. //map<TArray>(iterator: _.ObjectIterator<T, TArray[]>, context?: any): _ChainOfArrays<TArray>;
  1912. /**
  1913. * Wrapped type `any[]`.
  1914. * @see _.map
  1915. **/
  1916. map<TResult>(iterator: _.ObjectIterator<T, TResult>, context?: any): _Chain<TResult>;
  1917. /**
  1918. * @see _.map
  1919. **/
  1920. collect<TResult>(iterator: _.ListIterator<T, TResult>, context?: any): _Chain<T>;
  1921. /**
  1922. * @see _.map
  1923. **/
  1924. collect<TResult>(iterator: _.ObjectIterator<T, TResult>, context?: any): _Chain<T>;
  1925. /**
  1926. * Wrapped type `any[]`.
  1927. * @see _.reduce
  1928. **/
  1929. reduce<TResult>(iterator: _.MemoIterator<T, TResult>, memo?: TResult, context?: any): _Chain<T>;
  1930. /**
  1931. * @see _.reduce
  1932. **/
  1933. inject<TResult>(iterator: _.MemoIterator<T, TResult>, memo?: TResult, context?: any): _Chain<T>;
  1934. /**
  1935. * @see _.reduce
  1936. **/
  1937. foldl<TResult>(iterator: _.MemoIterator<T, TResult>, memo?: TResult, context?: any): _Chain<T>;
  1938. /**
  1939. * Wrapped type `any[]`.
  1940. * @see _.reduceRight
  1941. **/
  1942. reduceRight<TResult>(iterator: _.MemoIterator<T, TResult>, memo?: TResult, context?: any): _Chain<T>;
  1943. /**
  1944. * @see _.reduceRight
  1945. **/
  1946. foldr<TResult>(iterator: _.MemoIterator<T, TResult>, memo?: TResult, context?: any): _Chain<T>;
  1947. /**
  1948. * Wrapped type `any[]`.
  1949. * @see _.find
  1950. **/
  1951. find(iterator: _.ListIterator<T, boolean>, context?: any): _ChainSingle<T>;
  1952. /**
  1953. * @see _.find
  1954. **/
  1955. detect(iterator: _.ListIterator<T, boolean>, context?: any): _Chain<T>;
  1956. /**
  1957. * Wrapped type `any[]`.
  1958. * @see _.filter
  1959. **/
  1960. filter(iterator: _.ListIterator<T, boolean>, context?: any): _Chain<T>;
  1961. /**
  1962. * @see _.filter
  1963. **/
  1964. select(iterator: _.ListIterator<T, boolean>, context?: any): _Chain<T>;
  1965. /**
  1966. * Wrapped type `any[]`.
  1967. * @see _.where
  1968. **/
  1969. where<U extends {}>(properties: U): _Chain<T>;
  1970. /**
  1971. * Wrapped type `any[]`.
  1972. * @see _.findWhere
  1973. **/
  1974. findWhere<U extends {}>(properties: U): _ChainSingle<T>;
  1975. /**
  1976. * Wrapped type `any[]`.
  1977. * @see _.reject
  1978. **/
  1979. reject(iterator: _.ListIterator<T, boolean>, context?: any): _Chain<T>;
  1980. /**
  1981. * Wrapped type `any[]`.
  1982. * @see _.all
  1983. **/
  1984. all(iterator?: _.ListIterator<T, boolean>, context?: any): _Chain<T>;
  1985. /**
  1986. * @see _.all
  1987. **/
  1988. every(iterator?: _.ListIterator<T, boolean>, context?: any): _Chain<T>;
  1989. /**
  1990. * Wrapped type `any[]`.
  1991. * @see _.any
  1992. **/
  1993. any(iterator?: _.ListIterator<T, boolean>, context?: any): _Chain<T>;
  1994. /**
  1995. * @see _.any
  1996. **/
  1997. some(iterator?: _.ListIterator<T, boolean>, context?: any): _Chain<T>;
  1998. /**
  1999. * Wrapped type `any[]`.
  2000. * @see _.contains
  2001. **/
  2002. contains(value: T): _Chain<T>;
  2003. /**
  2004. * Alias for 'contains'.
  2005. * @see contains
  2006. **/
  2007. include(value: T): _Chain<T>;
  2008. /**
  2009. * Wrapped type `any[]`.
  2010. * @see _.invoke
  2011. **/
  2012. invoke(methodName: string, ...arguments: any[]): _Chain<T>;
  2013. /**
  2014. * Wrapped type `any[]`.
  2015. * @see _.pluck
  2016. **/
  2017. pluck(propertyName: string): _Chain<any>;
  2018. /**
  2019. * Wrapped type `number[]`.
  2020. * @see _.max
  2021. **/
  2022. max(): _ChainSingle<T>;
  2023. /**
  2024. * Wrapped type `any[]`.
  2025. * @see _.max
  2026. **/
  2027. max(iterator: _.ListIterator<T, number>, context?: any): _ChainSingle<T>;
  2028. /**
  2029. * Wrapped type `any[]`.
  2030. * @see _.max
  2031. **/
  2032. max(iterator?: _.ListIterator<T, any>, context?: any): _ChainSingle<T>;
  2033. /**
  2034. * Wrapped type `number[]`.
  2035. * @see _.min
  2036. **/
  2037. min(): _ChainSingle<T>;
  2038. /**
  2039. * Wrapped type `any[]`.
  2040. * @see _.min
  2041. **/
  2042. min(iterator: _.ListIterator<T, number>, context?: any): _ChainSingle<T>;
  2043. /**
  2044. * Wrapped type `any[]`.
  2045. * @see _.min
  2046. **/
  2047. min(iterator?: _.ListIterator<T, any>, context?: any): _ChainSingle<T>;
  2048. /**
  2049. * Wrapped type `any[]`.
  2050. * @see _.sortBy
  2051. **/
  2052. sortBy(iterator?: _.ListIterator<T, any>, context?: any): _Chain<T>;
  2053. /**
  2054. * Wrapped type `any[]`.
  2055. * @see _.sortBy
  2056. **/
  2057. sortBy(iterator: string, context?: any): _Chain<T>;
  2058. /**
  2059. * Wrapped type `any[]`.
  2060. * @see _.groupBy
  2061. **/
  2062. groupBy(iterator?: _.ListIterator<T, any>, context?: any): _Chain<T>;
  2063. /**
  2064. * Wrapped type `any[]`.
  2065. * @see _.groupBy
  2066. **/
  2067. groupBy(iterator: string, context?: any): _Chain<T>;
  2068. /**
  2069. * Wrapped type `any[]`.
  2070. * @see _.indexBy
  2071. **/
  2072. indexBy(iterator: _.ListIterator<T, any>, context?: any): _Chain<T>;
  2073. /**
  2074. * Wrapped type `any[]`.
  2075. * @see _.indexBy
  2076. **/
  2077. indexBy(iterator: string, context?: any): _Chain<T>;
  2078. /**
  2079. * Wrapped type `any[]`.
  2080. * @see _.countBy
  2081. **/
  2082. countBy(iterator?: _.ListIterator<T, any>, context?: any): _Chain<T>;
  2083. /**
  2084. * Wrapped type `any[]`.
  2085. * @see _.countBy
  2086. **/
  2087. countBy(iterator: string, context?: any): _Chain<T>;
  2088. /**
  2089. * Wrapped type `any[]`.
  2090. * @see _.shuffle
  2091. **/
  2092. shuffle(): _Chain<T>;
  2093. /**
  2094. * Wrapped type `any[]`.
  2095. * @see _.sample
  2096. **/
  2097. sample<T>(n: number): _Chain<T>;
  2098. /**
  2099. * @see _.sample
  2100. **/
  2101. sample<T>(): _Chain<T>;
  2102. /**
  2103. * Wrapped type `any`.
  2104. * @see _.toArray
  2105. **/
  2106. toArray(): _Chain<T>;
  2107. /**
  2108. * Wrapped type `any`.
  2109. * @see _.size
  2110. **/
  2111. size(): _Chain<T>;
  2112. /*********
  2113. * Arrays *
  2114. **********/
  2115. /**
  2116. * Wrapped type `any[]`.
  2117. * @see _.first
  2118. **/
  2119. first(): _Chain<T>;
  2120. /**
  2121. * Wrapped type `any[]`.
  2122. * @see _.first
  2123. **/
  2124. first(n: number): _Chain<T>;
  2125. /**
  2126. * @see _.first
  2127. **/
  2128. head(): _Chain<T>;
  2129. /**
  2130. * @see _.first
  2131. **/
  2132. head(n: number): _Chain<T>;
  2133. /**
  2134. * @see _.first
  2135. **/
  2136. take(): _Chain<T>;
  2137. /**
  2138. * @see _.first
  2139. **/
  2140. take(n: number): _Chain<T>;
  2141. /**
  2142. * Wrapped type `any[]`.
  2143. * @see _.initial
  2144. **/
  2145. initial(n?: number): _Chain<T>;
  2146. /**
  2147. * Wrapped type `any[]`.
  2148. * @see _.last
  2149. **/
  2150. last(): _Chain<T>;
  2151. /**
  2152. * Wrapped type `any[]`.
  2153. * @see _.last
  2154. **/
  2155. last(n: number): _Chain<T>;
  2156. /**
  2157. * Wrapped type `any[]`.
  2158. * @see _.rest
  2159. **/
  2160. rest(n?: number): _Chain<T>;
  2161. /**
  2162. * @see _.rest
  2163. **/
  2164. tail(n?: number): _Chain<T>;
  2165. /**
  2166. * @see _.rest
  2167. **/
  2168. drop(n?: number): _Chain<T>;
  2169. /**
  2170. * Wrapped type `any[]`.
  2171. * @see _.compact
  2172. **/
  2173. compact(): _Chain<T>;
  2174. /**
  2175. * Wrapped type `any`.
  2176. * @see _.flatten
  2177. **/
  2178. flatten(shallow?: boolean): _Chain<any>;
  2179. /**
  2180. * Wrapped type `any[]`.
  2181. * @see _.without
  2182. **/
  2183. without(...values: T[]): _Chain<T>;
  2184. /**
  2185. * Wrapped type `any[][]`.
  2186. * @see _.union
  2187. **/
  2188. union(...arrays: _.List<T>[]): _Chain<T>;
  2189. /**
  2190. * Wrapped type `any[][]`.
  2191. * @see _.intersection
  2192. **/
  2193. intersection(...arrays: _.List<T>[]): _Chain<T>;
  2194. /**
  2195. * Wrapped type `any[]`.
  2196. * @see _.difference
  2197. **/
  2198. difference(...others: _.List<T>[]): _Chain<T>;
  2199. /**
  2200. * Wrapped type `any[]`.
  2201. * @see _.uniq
  2202. **/
  2203. uniq(isSorted?: boolean, iterator?: _.ListIterator<T, any>): _Chain<T>;
  2204. /**
  2205. * Wrapped type `any[]`.
  2206. * @see _.uniq
  2207. **/
  2208. uniq<TSort>(iterator?: _.ListIterator<T, TSort>, context?: any): _Chain<T>;
  2209. /**
  2210. * @see _.uniq
  2211. **/
  2212. unique<TSort>(isSorted?: boolean, iterator?: _.ListIterator<T, TSort>): _Chain<T>;
  2213. /**
  2214. * @see _.uniq
  2215. **/
  2216. unique<TSort>(iterator?: _.ListIterator<T, TSort>, context?: any): _Chain<T>;
  2217. /**
  2218. * Wrapped type `any[][]`.
  2219. * @see _.zip
  2220. **/
  2221. zip(...arrays: any[][]): _Chain<T>;
  2222. /**
  2223. * Wrapped type `any[][]`.
  2224. * @see _.object
  2225. **/
  2226. object(...keyValuePairs: any[][]): _Chain<T>;
  2227. /**
  2228. * @see _.object
  2229. **/
  2230. object(values?: any): _Chain<T>;
  2231. /**
  2232. * Wrapped type `any[]`.
  2233. * @see _.indexOf
  2234. **/
  2235. indexOf(value: T, isSorted?: boolean): _Chain<T>;
  2236. /**
  2237. * @see _.indexOf
  2238. **/
  2239. indexOf(value: T, startFrom: number): _Chain<T>;
  2240. /**
  2241. * Wrapped type `any[]`.
  2242. * @see _.lastIndexOf
  2243. **/
  2244. lastIndexOf(value: T, from?: number): _Chain<T>;
  2245. /**
  2246. * Wrapped type `any[]`.
  2247. * @see _.sortedIndex
  2248. **/
  2249. sortedIndex(value: T, iterator?: (x: T) => any, context?: any): _Chain<T>;
  2250. /**
  2251. * Wrapped type `number`.
  2252. * @see _.range
  2253. **/
  2254. range(stop: number, step?: number): _Chain<T>;
  2255. /**
  2256. * Wrapped type `number`.
  2257. * @see _.range
  2258. **/
  2259. range(): _Chain<T>;
  2260. /* ***********
  2261. * Functions *
  2262. ************ */
  2263. /**
  2264. * Wrapped type `Function`.
  2265. * @see _.bind
  2266. **/
  2267. bind(object: any, ...arguments: any[]): _Chain<T>;
  2268. /**
  2269. * Wrapped type `object`.
  2270. * @see _.bindAll
  2271. **/
  2272. bindAll(...methodNames: string[]): _Chain<T>;
  2273. /**
  2274. * Wrapped type `Function`.
  2275. * @see _.partial
  2276. **/
  2277. partial(...arguments: any[]): _Chain<T>;
  2278. /**
  2279. * Wrapped type `Function`.
  2280. * @see _.memoize
  2281. **/
  2282. memoize(hashFn?: (n: any) => string): _Chain<T>;
  2283. /**
  2284. * Wrapped type `Function`.
  2285. * @see _.defer
  2286. **/
  2287. defer(...arguments: any[]): _Chain<T>;
  2288. /**
  2289. * Wrapped type `Function`.
  2290. * @see _.delay
  2291. **/
  2292. delay(wait: number, ...arguments: any[]): _Chain<T>;
  2293. /**
  2294. * @see _.delay
  2295. **/
  2296. delay(...arguments: any[]): _Chain<T>;
  2297. /**
  2298. * Wrapped type `Function`.
  2299. * @see _.throttle
  2300. **/
  2301. throttle(wait: number, options?: _.ThrottleSettings): _Chain<T>;
  2302. /**
  2303. * Wrapped type `Function`.
  2304. * @see _.debounce
  2305. **/
  2306. debounce(wait: number, immediate?: boolean): _Chain<T>;
  2307. /**
  2308. * Wrapped type `Function`.
  2309. * @see _.once
  2310. **/
  2311. once(): _Chain<T>;
  2312. /**
  2313. * Wrapped type `number`.
  2314. * @see _.after
  2315. **/
  2316. after(func: Function): _Chain<T>;
  2317. /**
  2318. * Wrapped type `Function`.
  2319. * @see _.wrap
  2320. **/
  2321. wrap(wrapper: Function): () => _Chain<T>;
  2322. /**
  2323. * Wrapped type `Function[]`.
  2324. * @see _.compose
  2325. **/
  2326. compose(...functions: Function[]): _Chain<T>;
  2327. /********* *
  2328. * Objects *
  2329. ********** */
  2330. /**
  2331. * Wrapped type `object`.
  2332. * @see _.keys
  2333. **/
  2334. keys(): _Chain<string>;
  2335. /**
  2336. * Wrapped type `object`.
  2337. * @see _.values
  2338. **/
  2339. values(): _Chain<T>;
  2340. /**
  2341. * Wrapped type `object`.
  2342. * @see _.pairs
  2343. **/
  2344. pairs(): _Chain<T>;
  2345. /**
  2346. * Wrapped type `object`.
  2347. * @see _.invert
  2348. **/
  2349. invert(): _Chain<T>;
  2350. /**
  2351. * Wrapped type `object`.
  2352. * @see _.functions
  2353. **/
  2354. functions(): _Chain<T>;
  2355. /**
  2356. * @see _.functions
  2357. **/
  2358. methods(): _Chain<T>;
  2359. /**
  2360. * Wrapped type `object`.
  2361. * @see _.extend
  2362. **/
  2363. extend(...sources: any[]): _Chain<T>;
  2364. /**
  2365. * Wrapped type `object`.
  2366. * @see _.pick
  2367. **/
  2368. pick(...keys: string[]): _Chain<T>;
  2369. /**
  2370. * Wrapped type `object`.
  2371. * @see _.omit
  2372. **/
  2373. omit(...keys: string[]): _Chain<T>;
  2374. /**
  2375. * Wrapped type `object`.
  2376. * @see _.defaults
  2377. **/
  2378. defaults(...defaults: any[]): _Chain<T>;
  2379. /**
  2380. * Wrapped type `any[]`.
  2381. * @see _.clone
  2382. **/
  2383. clone(): _Chain<T>;
  2384. /**
  2385. * Wrapped type `object`.
  2386. * @see _.tap
  2387. **/
  2388. tap(interceptor: (...as: any[]) => any): _Chain<T>;
  2389. /**
  2390. * Wrapped type `object`.
  2391. * @see _.has
  2392. **/
  2393. has(key: string): _Chain<T>;
  2394. /**
  2395. * Wrapped type `object`.
  2396. * @see _.isEqual
  2397. **/
  2398. isEqual(other: any): _Chain<T>;
  2399. /**
  2400. * Wrapped type `object`.
  2401. * @see _.isEmpty
  2402. **/
  2403. isEmpty(): _Chain<T>;
  2404. /**
  2405. * Wrapped type `object`.
  2406. * @see _.isElement
  2407. **/
  2408. isElement(): _Chain<T>;
  2409. /**
  2410. * Wrapped type `object`.
  2411. * @see _.isArray
  2412. **/
  2413. isArray(): _Chain<T>;
  2414. /**
  2415. * Wrapped type `object`.
  2416. * @see _.isObject
  2417. **/
  2418. isObject(): _Chain<T>;
  2419. /**
  2420. * Wrapped type `object`.
  2421. * @see _.isArguments
  2422. **/
  2423. isArguments(): _Chain<T>;
  2424. /**
  2425. * Wrapped type `object`.
  2426. * @see _.isFunction
  2427. **/
  2428. isFunction(): _Chain<T>;
  2429. /**
  2430. * Wrapped type `object`.
  2431. * @see _.isString
  2432. **/
  2433. isString(): _Chain<T>;
  2434. /**
  2435. * Wrapped type `object`.
  2436. * @see _.isNumber
  2437. **/
  2438. isNumber(): _Chain<T>;
  2439. /**
  2440. * Wrapped type `object`.
  2441. * @see _.isFinite
  2442. **/
  2443. isFinite(): _Chain<T>;
  2444. /**
  2445. * Wrapped type `object`.
  2446. * @see _.isBoolean
  2447. **/
  2448. isBoolean(): _Chain<T>;
  2449. /**
  2450. * Wrapped type `object`.
  2451. * @see _.isDate
  2452. **/
  2453. isDate(): _Chain<T>;
  2454. /**
  2455. * Wrapped type `object`.
  2456. * @see _.isRegExp
  2457. **/
  2458. isRegExp(): _Chain<T>;
  2459. /**
  2460. * Wrapped type `object`.
  2461. * @see _.isNaN
  2462. **/
  2463. isNaN(): _Chain<T>;
  2464. /**
  2465. * Wrapped type `object`.
  2466. * @see _.isNull
  2467. **/
  2468. isNull(): _Chain<T>;
  2469. /**
  2470. * Wrapped type `object`.
  2471. * @see _.isUndefined
  2472. **/
  2473. isUndefined(): _Chain<T>;
  2474. /********* *
  2475. * Utility *
  2476. ********** */
  2477. /**
  2478. * Wrapped type `any`.
  2479. * @see _.identity
  2480. **/
  2481. identity(): _Chain<T>;
  2482. /**
  2483. * Wrapped type `number`.
  2484. * @see _.times
  2485. **/
  2486. times<TResult>(iterator: (n: number) => TResult, context?: any): _Chain<T>;
  2487. /**
  2488. * Wrapped type `number`.
  2489. * @see _.random
  2490. **/
  2491. random(): _Chain<T>;
  2492. /**
  2493. * Wrapped type `number`.
  2494. * @see _.random
  2495. **/
  2496. random(max: number): _Chain<T>;
  2497. /**
  2498. * Wrapped type `object`.
  2499. * @see _.mixin
  2500. **/
  2501. mixin(): _Chain<T>;
  2502. /**
  2503. * Wrapped type `string`.
  2504. * @see _.uniqueId
  2505. **/
  2506. uniqueId(): _Chain<T>;
  2507. /**
  2508. * Wrapped type `string`.
  2509. * @see _.escape
  2510. **/
  2511. escape(): _Chain<T>;
  2512. /**
  2513. * Wrapped type `object`.
  2514. * @see _.result
  2515. **/
  2516. result(property: string): _Chain<T>;
  2517. /**
  2518. * Wrapped type `string`.
  2519. * @see _.template
  2520. **/
  2521. template(data?: any, settings?: _.TemplateSettings): (...data: any[]) => _Chain<T>;
  2522. /********** *
  2523. * Chaining *
  2524. *********** */
  2525. /**
  2526. * Wrapped type `any`.
  2527. * @see _.chain
  2528. **/
  2529. chain(): _Chain<T>;
  2530. /**
  2531. * Wrapped type `any`.
  2532. * @see _.value
  2533. **/
  2534. value<TResult>(): T[];
  2535. }
  2536. interface _ChainSingle<T> {
  2537. value(): T;
  2538. }
  2539. interface _ChainOfArrays<T> extends _Chain<T[]> {
  2540. flatten(): _Chain<T>;
  2541. }
  2542. declare var _: UnderscoreStatic;
  2543. declare module "underscore" {
  2544. export = _;
  2545. }