PageRenderTime 31ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/underscore/underscore.d.ts

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