PageRenderTime 30ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 1ms

/MvsWebFactory/typings/underscore/underscore.d.ts

https://gitlab.com/iyulab/MvsWebSeed
TypeScript Typings | 1573 lines | 459 code | 182 blank | 932 comment | 1 complexity | 8059a5338c808ae439fa9dff1113e62b MD5 | raw file
  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 Collection<T> { }
  38. // Common interface between Arrays and jQuery objects
  39. interface List<T> extends Collection<T> {
  40. [index: number]: T;
  41. length: number;
  42. }
  43. interface Dictionary<T> extends Collection<T> {
  44. [index: string]: T;
  45. }
  46. interface ListIterator<T, TResult> {
  47. (value: T, index: number, list: List<T>): TResult;
  48. }
  49. interface ObjectIterator<T, TResult> {
  50. (element: T, key: string, list: Dictionary<T>): TResult;
  51. }
  52. interface MemoIterator<T, TResult> {
  53. (prev: TResult, curr: T, index: number, list: List<T>): TResult;
  54. }
  55. interface MemoObjectIterator<T, TResult> {
  56. (prev: TResult, curr: T, key: string, list: Dictionary<T>): TResult;
  57. }
  58. }
  59. interface UnderscoreStatic {
  60. /**
  61. * Underscore OOP Wrapper, all Underscore functions that take an object
  62. * as the first parameter can be invoked through this function.
  63. * @param key First argument to Underscore object functions.
  64. **/
  65. <T>(value: Array<T>): Underscore<T>;
  66. <T>(value: T): Underscore<T>;
  67. /* *************
  68. * Collections *
  69. ************* */
  70. /**
  71. * Iterates over a list of elements, yielding each in turn to an iterator function. The iterator is
  72. * bound to the context object, if one is passed. Each invocation of iterator is called with three
  73. * arguments: (element, index, list). If list is a JavaScript object, iterator's arguments will be
  74. * (value, key, object). Delegates to the native forEach function if it exists.
  75. * @param list Iterates over this list of elements.
  76. * @param iterator Iterator function for each element `list`.
  77. * @param context 'this' object in `iterator`, optional.
  78. **/
  79. each<T>(
  80. list: _.List<T>,
  81. iterator: _.ListIterator<T, void>,
  82. context?: any): _.List<T>;
  83. /**
  84. * @see _.each
  85. * @param object Iterates over properties of this object.
  86. * @param iterator Iterator function for each property on `object`.
  87. * @param context 'this' object in `iterator`, optional.
  88. **/
  89. each<T>(
  90. object: _.Dictionary<T>,
  91. iterator: _.ObjectIterator<T, void>,
  92. context?: any): _.Dictionary<T>;
  93. /**
  94. * @see _.each
  95. **/
  96. forEach<T>(
  97. list: _.List<T>,
  98. iterator: _.ListIterator<T, void>,
  99. context?: any): _.List<T>;
  100. /**
  101. * @see _.each
  102. **/
  103. forEach<T>(
  104. object: _.Dictionary<T>,
  105. iterator: _.ObjectIterator<T, void>,
  106. context?: any): _.Dictionary<T>;
  107. /**
  108. * Produces a new array of values by mapping each value in list through a transformation function
  109. * (iterator). If the native map method exists, it will be used instead. If list is a JavaScript
  110. * object, iterator's arguments will be (value, key, object).
  111. * @param list Maps the elements of this array.
  112. * @param iterator Map iterator function for each element in `list`.
  113. * @param context `this` object in `iterator`, optional.
  114. * @return The mapped array result.
  115. **/
  116. map<T, TResult>(
  117. list: _.List<T>,
  118. iterator: _.ListIterator<T, TResult>,
  119. context?: any): TResult[];
  120. /**
  121. * @see _.map
  122. * @param object Maps the properties of this object.
  123. * @param iterator Map iterator function for each property on `object`.
  124. * @param context `this` object in `iterator`, optional.
  125. * @return The mapped object result.
  126. **/
  127. map<T, TResult>(
  128. object: _.Dictionary<T>,
  129. iterator: _.ObjectIterator<T, TResult>,
  130. context?: any): TResult[];
  131. /**
  132. * @see _.map
  133. **/
  134. collect<T, TResult>(
  135. list: _.List<T>,
  136. iterator: _.ListIterator<T, TResult>,
  137. context?: any): TResult[];
  138. /**
  139. * @see _.map
  140. **/
  141. collect<T, TResult>(
  142. object: _.Dictionary<T>,
  143. iterator: _.ObjectIterator<T, TResult>,
  144. context?: any): TResult[];
  145. /**
  146. * Also known as inject and foldl, reduce boils down a list of values into a single value.
  147. * Memo is the initial state of the reduction, and each successive step of it should be
  148. * returned by iterator. The iterator is passed four arguments: the memo, then the value
  149. * and index (or key) of the iteration, and finally a reference to the entire list.
  150. * @param list Reduces the elements of this array.
  151. * @param iterator Reduce iterator function for each element in `list`.
  152. * @param memo Initial reduce state.
  153. * @param context `this` object in `iterator`, optional.
  154. * @return Reduced object result.
  155. **/
  156. reduce<T, TResult>(
  157. list: _.Collection<T>,
  158. iterator: _.MemoIterator<T, TResult>,
  159. memo?: TResult,
  160. context?: any): TResult;
  161. reduce<T, TResult>(
  162. list: _.Dictionary<T>,
  163. iterator: _.MemoObjectIterator<T, TResult>,
  164. memo?: TResult,
  165. context?: any): TResult;
  166. /**
  167. * @see _.reduce
  168. **/
  169. inject<T, TResult>(
  170. list: _.Collection<T>,
  171. iterator: _.MemoIterator<T, TResult>,
  172. memo?: TResult,
  173. context?: any): TResult;
  174. /**
  175. * @see _.reduce
  176. **/
  177. foldl<T, TResult>(
  178. list: _.Collection<T>,
  179. iterator: _.MemoIterator<T, TResult>,
  180. memo?: TResult,
  181. context?: any): TResult;
  182. /**
  183. * The right-associative version of reduce. Delegates to the JavaScript 1.8 version of
  184. * reduceRight, if it exists. `foldr` is not as useful in JavaScript as it would be in a
  185. * language with lazy evaluation.
  186. * @param list Reduces the elements of this array.
  187. * @param iterator Reduce iterator function for each element in `list`.
  188. * @param memo Initial reduce state.
  189. * @param context `this` object in `iterator`, optional.
  190. * @return Reduced object result.
  191. **/
  192. reduceRight<T, TResult>(
  193. list: _.Collection<T>,
  194. iterator: _.MemoIterator<T, TResult>,
  195. memo?: TResult,
  196. context?: any): TResult;
  197. /**
  198. * @see _.reduceRight
  199. **/
  200. foldr<T, TResult>(
  201. list: _.Collection<T>,
  202. iterator: _.MemoIterator<T, TResult>,
  203. memo?: TResult,
  204. context?: any): TResult;
  205. /**
  206. * Looks through each value in the list, returning the first one that passes a truth
  207. * test (iterator). The function returns as soon as it finds an acceptable element,
  208. * and doesn't traverse the entire list.
  209. * @param list Searches for a value in this list.
  210. * @param iterator Search iterator function for each element in `list`.
  211. * @param context `this` object in `iterator`, optional.
  212. * @return The first acceptable found element in `list`, if nothing is found undefined/null is returned.
  213. **/
  214. find<T>(
  215. list: _.List<T>,
  216. iterator: _.ListIterator<T, boolean>,
  217. context?: any): T;
  218. /**
  219. * @see _.find
  220. **/
  221. find<T>(
  222. object: _.Dictionary<T>,
  223. iterator: _.ObjectIterator<T, boolean>,
  224. context?: any): T;
  225. /**
  226. * @see _.find
  227. **/
  228. find<T, U extends {}>(
  229. object: _.List<T>|_.Dictionary<T>,
  230. iterator: U): T;
  231. /**
  232. * @see _.find
  233. **/
  234. find<T>(
  235. object: _.List<T>|_.Dictionary<T>,
  236. iterator: string): T;
  237. /**
  238. * @see _.find
  239. **/
  240. detect<T>(
  241. list: _.List<T>,
  242. iterator: _.ListIterator<T, boolean>,
  243. context?: any): T;
  244. /**
  245. * @see _.find
  246. **/
  247. detect<T>(
  248. object: _.Dictionary<T>,
  249. iterator: _.ObjectIterator<T, boolean>,
  250. context?: any): T;
  251. /**
  252. * @see _.find
  253. **/
  254. detect<T, U extends {}>(
  255. object: _.List<T>|_.Dictionary<T>,
  256. iterator: U): T;
  257. /**
  258. * @see _.find
  259. **/
  260. detect<T>(
  261. object: _.List<T>|_.Dictionary<T>,
  262. iterator: string): T;
  263. /**
  264. * Looks through each value in the list, returning the index of the first one that passes a truth
  265. * test (iterator). The function returns as soon as it finds an acceptable element,
  266. * and doesn't traverse the entire list.
  267. * @param list Searches for a value in this list.
  268. * @param iterator Search iterator function for each element in `list`.
  269. * @param context `this` object in `iterator`, optional.
  270. * @return The index of the first acceptable found element in `list`, if nothing is found -1 is returned.
  271. **/
  272. findIndex<T>(
  273. list: _.List<T>,
  274. iterator: _.ListIterator<T, boolean>,
  275. context?: any): number;
  276. /**
  277. * Looks through each value in the list, returning an array of all the values that pass a truth
  278. * test (iterator). Delegates to the native filter method, if it exists.
  279. * @param list Filter elements out of this list.
  280. * @param iterator Filter iterator function for each element in `list`.
  281. * @param context `this` object in `iterator`, optional.
  282. * @return The filtered list of elements.
  283. **/
  284. filter<T>(
  285. list: _.List<T>,
  286. iterator: _.ListIterator<T, boolean>,
  287. context?: any): T[];
  288. /**
  289. * @see _.filter
  290. **/
  291. filter<T>(
  292. object: _.Dictionary<T>,
  293. iterator: _.ObjectIterator<T, boolean>,
  294. context?: any): T[];
  295. /**
  296. * @see _.filter
  297. **/
  298. select<T>(
  299. list: _.List<T>,
  300. iterator: _.ListIterator<T, boolean>,
  301. context?: any): T[];
  302. /**
  303. * @see _.filter
  304. **/
  305. select<T>(
  306. object: _.Dictionary<T>,
  307. iterator: _.ObjectIterator<T, boolean>,
  308. context?: any): T[];
  309. /**
  310. * Looks through each value in the list, returning an array of all the values that contain all
  311. * of the key-value pairs listed in properties.
  312. * @param list List to match elements again `properties`.
  313. * @param properties The properties to check for on each element within `list`.
  314. * @return The elements within `list` that contain the required `properties`.
  315. **/
  316. where<T, U extends {}>(
  317. list: _.List<T>,
  318. properties: U): T[];
  319. /**
  320. * Looks through the list and returns the first value that matches all of the key-value pairs listed in properties.
  321. * @param list Search through this list's elements for the first object with all `properties`.
  322. * @param properties Properties to look for on the elements within `list`.
  323. * @return The first element in `list` that has all `properties`.
  324. **/
  325. findWhere<T, U extends {}>(
  326. list: _.List<T>,
  327. properties: U): T;
  328. /**
  329. * Returns the values in list without the elements that the truth test (iterator) passes.
  330. * The opposite of filter.
  331. * Return all the elements for which a truth test fails.
  332. * @param list Reject elements within this list.
  333. * @param iterator Reject iterator function for each element in `list`.
  334. * @param context `this` object in `iterator`, optional.
  335. * @return The rejected list of elements.
  336. **/
  337. reject<T>(
  338. list: _.List<T>,
  339. iterator: _.ListIterator<T, boolean>,
  340. context?: any): T[];
  341. /**
  342. * @see _.reject
  343. **/
  344. reject<T>(
  345. object: _.Dictionary<T>,
  346. iterator: _.ObjectIterator<T, boolean>,
  347. context?: any): T[];
  348. /**
  349. * Returns true if all of the values in the list pass the iterator truth test. Delegates to the
  350. * native method every, if present.
  351. * @param list Truth test against all elements within this list.
  352. * @param iterator Trust test iterator function for each element in `list`.
  353. * @param context `this` object in `iterator`, optional.
  354. * @return True if all elements passed the truth test, otherwise false.
  355. **/
  356. every<T>(
  357. list: _.List<T>,
  358. iterator?: _.ListIterator<T, boolean>,
  359. context?: any): boolean;
  360. /**
  361. * @see _.every
  362. **/
  363. every<T>(
  364. list: _.Dictionary<T>,
  365. iterator?: _.ObjectIterator<T, boolean>,
  366. context?: any): boolean;
  367. /**
  368. * @see _.every
  369. **/
  370. all<T>(
  371. list: _.List<T>,
  372. iterator?: _.ListIterator<T, boolean>,
  373. context?: any): boolean;
  374. /**
  375. * @see _.every
  376. **/
  377. all<T>(
  378. list: _.Dictionary<T>,
  379. iterator?: _.ObjectIterator<T, boolean>,
  380. context?: any): boolean;
  381. /**
  382. * Returns true if any of the values in the list pass the iterator truth test. Short-circuits and
  383. * stops traversing the list if a true element is found. Delegates to the native method some, if present.
  384. * @param list Truth test against all elements within this list.
  385. * @param iterator Trust test iterator function for each element in `list`.
  386. * @param context `this` object in `iterator`, optional.
  387. * @return True if any elements passed the truth test, otherwise false.
  388. **/
  389. some<T>(
  390. list: _.List<T>,
  391. iterator?: _.ListIterator<T, boolean>,
  392. context?: any): boolean;
  393. /**
  394. * @see _.some
  395. **/
  396. some<T>(
  397. object: _.Dictionary<T>,
  398. iterator?: _.ObjectIterator<T, boolean>,
  399. context?: any): boolean;
  400. /**
  401. * @see _.some
  402. **/
  403. any<T>(
  404. list: _.List<T>,
  405. iterator?: _.ListIterator<T, boolean>,
  406. context?: any): boolean;
  407. /**
  408. * @see _.some
  409. **/
  410. any<T>(
  411. object: _.Dictionary<T>,
  412. iterator?: _.ObjectIterator<T, boolean>,
  413. context?: any): boolean;
  414. /**
  415. * Returns true if the value is present in the list. Uses indexOf internally,
  416. * if list is an Array.
  417. * @param list Checks each element to see if `value` is present.
  418. * @param value The value to check for within `list`.
  419. * @return True if `value` is present in `list`, otherwise false.
  420. **/
  421. contains<T>(
  422. list: _.List<T>,
  423. value: T): boolean;
  424. /**
  425. * @see _.contains
  426. **/
  427. contains<T>(
  428. object: _.Dictionary<T>,
  429. value: T): boolean;
  430. /**
  431. * @see _.contains
  432. **/
  433. include<T>(
  434. list: _.Collection<T>,
  435. value: T): boolean;
  436. /**
  437. * @see _.contains
  438. **/
  439. include<T>(
  440. object: _.Dictionary<T>,
  441. value: T): boolean;
  442. /**
  443. * Calls the method named by methodName on each value in the list. Any extra arguments passed to
  444. * invoke will be forwarded on to the method invocation.
  445. * @param list The element's in this list will each have the method `methodName` invoked.
  446. * @param methodName The method's name to call on each element within `list`.
  447. * @param arguments Additional arguments to pass to the method `methodName`.
  448. **/
  449. invoke<T extends {}>(
  450. list: _.List<T>,
  451. methodName: string,
  452. ...arguments: any[]): any;
  453. /**
  454. * A convenient version of what is perhaps the most common use-case for map: extracting a list of
  455. * property values.
  456. * @param list The list to pluck elements out of that have the property `propertyName`.
  457. * @param propertyName The property to look for on each element within `list`.
  458. * @return The list of elements within `list` that have the property `propertyName`.
  459. **/
  460. pluck<T extends {}>(
  461. list: _.List<T>,
  462. propertyName: string): any[];
  463. /**
  464. * Returns the maximum value in list.
  465. * @param list Finds the maximum value in this list.
  466. * @return Maximum value in `list`.
  467. **/
  468. max(list: _.List<number>): number;
  469. /**
  470. * Returns the maximum value in list. If iterator is passed, it will be used on each value to generate
  471. * the criterion by which the value is ranked.
  472. * @param list Finds the maximum value in this list.
  473. * @param iterator Compares each element in `list` to find the maximum value.
  474. * @param context `this` object in `iterator`, optional.
  475. * @return The maximum element within `list`.
  476. **/
  477. max<T>(
  478. list: _.List<T>,
  479. iterator?: _.ListIterator<T, any>,
  480. context?: any): T;
  481. /**
  482. * Returns the minimum value in list.
  483. * @param list Finds the minimum value in this list.
  484. * @return Minimum value in `list`.
  485. **/
  486. min(list: _.List<number>): number;
  487. /**
  488. * Returns the minimum value in list. If iterator is passed, it will be used on each value to generate
  489. * the criterion by which the value is ranked.
  490. * @param list Finds the minimum value in this list.
  491. * @param iterator Compares each element in `list` to find the minimum value.
  492. * @param context `this` object in `iterator`, optional.
  493. * @return The minimum element within `list`.
  494. **/
  495. min<T>(
  496. list: _.List<T>,
  497. iterator?: _.ListIterator<T, any>,
  498. context?: any): T;
  499. /**
  500. * Returns a sorted copy of list, ranked in ascending order by the results of running each value
  501. * through iterator. Iterator may also be the string name of the property to sort by (eg. length).
  502. * @param list Sorts this list.
  503. * @param iterator Sort iterator for each element within `list`.
  504. * @param context `this` object in `iterator`, optional.
  505. * @return A sorted copy of `list`.
  506. **/
  507. sortBy<T, TSort>(
  508. list: _.List<T>,
  509. iterator?: _.ListIterator<T, TSort>,
  510. context?: any): T[];
  511. /**
  512. * @see _.sortBy
  513. * @param iterator Sort iterator for each element within `list`.
  514. **/
  515. sortBy<T>(
  516. list: _.List<T>,
  517. iterator: string,
  518. context?: any): T[];
  519. /**
  520. * Splits a collection into sets, grouped by the result of running each value through iterator.
  521. * If iterator is a string instead of a function, groups by the property named by iterator on
  522. * each of the values.
  523. * @param list Groups this list.
  524. * @param iterator Group iterator for each element within `list`, return the key to group the element by.
  525. * @param context `this` object in `iterator`, optional.
  526. * @return An object with the group names as properties where each property contains the grouped elements from `list`.
  527. **/
  528. groupBy<T>(
  529. list: _.List<T>,
  530. iterator?: _.ListIterator<T, any>,
  531. context?: any): _.Dictionary<T[]>;
  532. /**
  533. * @see _.groupBy
  534. * @param iterator Property on each object to group them by.
  535. **/
  536. groupBy<T>(
  537. list: _.List<T>,
  538. iterator: string,
  539. context?: any): _.Dictionary<T[]>;
  540. /**
  541. * Given a `list`, and an `iterator` function that returns a key for each element in the list (or a property name),
  542. * returns an object with an index of each item. Just like _.groupBy, but for when you know your keys are unique.
  543. **/
  544. indexBy<T>(
  545. list: _.List<T>,
  546. iterator: _.ListIterator<T, any>,
  547. context?: any): _.Dictionary<T>;
  548. /**
  549. * @see _.indexBy
  550. * @param iterator Property on each object to index them by.
  551. **/
  552. indexBy<T>(
  553. list: _.List<T>,
  554. iterator: string,
  555. context?: any): _.Dictionary<T>;
  556. /**
  557. * Sorts a list into groups and returns a count for the number of objects in each group. Similar
  558. * to groupBy, but instead of returning a list of values, returns a count for the number of values
  559. * in that group.
  560. * @param list Group elements in this list and then count the number of elements in each group.
  561. * @param iterator Group iterator for each element within `list`, return the key to group the element by.
  562. * @param context `this` object in `iterator`, optional.
  563. * @return An object with the group names as properties where each property contains the number of elements in that group.
  564. **/
  565. countBy<T>(
  566. list: _.List<T>,
  567. iterator?: _.ListIterator<T, any>,
  568. context?: any): _.Dictionary<number>;
  569. /**
  570. * @see _.countBy
  571. * @param iterator Function name
  572. **/
  573. countBy<T>(
  574. list: _.List<T>,
  575. iterator: string,
  576. context?: any): _.Dictionary<number>;
  577. /**
  578. * Returns a shuffled copy of the list, using a version of the Fisher-Yates shuffle.
  579. * @param list List to shuffle.
  580. * @return Shuffled copy of `list`.
  581. **/
  582. shuffle<T>(list: _.Collection<T>): T[];
  583. /**
  584. * 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.
  585. * @param list List to sample.
  586. * @return Random sample of `n` elements in `list`.
  587. **/
  588. sample<T>(list: _.Collection<T>, n: number): T[];
  589. /**
  590. * @see _.sample
  591. **/
  592. sample<T>(list: _.Collection<T>): T;
  593. /**
  594. * Converts the list (anything that can be iterated over), into a real Array. Useful for transmuting
  595. * the arguments object.
  596. * @param list object to transform into an array.
  597. * @return `list` as an array.
  598. **/
  599. toArray<T>(list: _.Collection<T>): T[];
  600. /**
  601. * Return the number of values in the list.
  602. * @param list Count the number of values/elements in this list.
  603. * @return Number of values in `list`.
  604. **/
  605. size<T>(list: _.Collection<T>): number;
  606. /**
  607. * Split array into two arrays:
  608. * one whose elements all satisfy predicate and one whose elements all do not satisfy predicate.
  609. * @param array Array to split in two.
  610. * @param iterator Filter iterator function for each element in `array`.
  611. * @param context `this` object in `iterator`, optional.
  612. * @return Array where Array[0] are the elements in `array` that satisfies the predicate, and Array[1] the elements that did not.
  613. **/
  614. partition<T>(
  615. array: Array<T>,
  616. iterator: _.ListIterator<T, boolean>,
  617. context?: any): T[][];
  618. /*********
  619. * Arrays *
  620. **********/
  621. /**
  622. * Returns the first element of an array. Passing n will return the first n elements of the array.
  623. * @param array Retrieves the first element of this array.
  624. * @return Returns the first element of `array`.
  625. **/
  626. first<T>(array: _.List<T>): T;
  627. /**
  628. * @see _.first
  629. * @param n Return more than one element from `array`.
  630. **/
  631. first<T>(
  632. array: _.List<T>,
  633. n: number): T[];
  634. /**
  635. * @see _.first
  636. **/
  637. head<T>(array: _.List<T>): T;
  638. /**
  639. * @see _.first
  640. **/
  641. head<T>(
  642. array: _.List<T>,
  643. n: number): T[];
  644. /**
  645. * @see _.first
  646. **/
  647. take<T>(array: _.List<T>): T;
  648. /**
  649. * @see _.first
  650. **/
  651. take<T>(
  652. array: _.List<T>,
  653. n: number): T[];
  654. /**
  655. * Returns everything but the last entry of the array. Especially useful on the arguments object.
  656. * Pass n to exclude the last n elements from the result.
  657. * @param array Retrieve all elements except the last `n`.
  658. * @param n Leaves this many elements behind, optional.
  659. * @return Returns everything but the last `n` elements of `array`.
  660. **/
  661. initial<T>(
  662. array: _.List<T>,
  663. n?: number): T[];
  664. /**
  665. * Returns the last element of an array. Passing n will return the last n elements of the array.
  666. * @param array Retrieves the last element of this array.
  667. * @return Returns the last element of `array`.
  668. **/
  669. last<T>(array: _.List<T>): T;
  670. /**
  671. * @see _.last
  672. * @param n Return more than one element from `array`.
  673. **/
  674. last<T>(
  675. array: _.List<T>,
  676. n: number): T[];
  677. /**
  678. * Returns the rest of the elements in an array. Pass an index to return the values of the array
  679. * from that index onward.
  680. * @param array The array to retrieve all but the first `index` elements.
  681. * @param n The index to start retrieving elements forward from, optional, default = 1.
  682. * @return Returns the elements of `array` from `index` to the end of `array`.
  683. **/
  684. rest<T>(
  685. array: _.List<T>,
  686. n?: number): T[];
  687. /**
  688. * @see _.rest
  689. **/
  690. tail<T>(
  691. array: _.List<T>,
  692. n?: number): T[];
  693. /**
  694. * @see _.rest
  695. **/
  696. drop<T>(
  697. array: _.List<T>,
  698. n?: number): T[];
  699. /**
  700. * Returns a copy of the array with all falsy values removed. In JavaScript, false, null, 0, "",
  701. * undefined and NaN are all falsy.
  702. * @param array Array to compact.
  703. * @return Copy of `array` without false values.
  704. **/
  705. compact<T>(array: _.List<T>): T[];
  706. /**
  707. * Flattens a nested array (the nesting can be to any depth). If you pass shallow, the array will
  708. * only be flattened a single level.
  709. * @param array The array to flatten.
  710. * @param shallow If true then only flatten one level, optional, default = false.
  711. * @return `array` flattened.
  712. **/
  713. flatten(
  714. array: _.List<any>,
  715. shallow?: boolean): any[];
  716. /**
  717. * Returns a copy of the array with all instances of the values removed.
  718. * @param array The array to remove `values` from.
  719. * @param values The values to remove from `array`.
  720. * @return Copy of `array` without `values`.
  721. **/
  722. without<T>(
  723. array: _.List<T>,
  724. ...values: T[]): T[];
  725. /**
  726. * Computes the union of the passed-in arrays: the list of unique items, in order, that are
  727. * present in one or more of the arrays.
  728. * @param arrays Array of arrays to compute the union of.
  729. * @return The union of elements within `arrays`.
  730. **/
  731. union<T>(...arrays: _.List<T>[]): T[];
  732. /**
  733. * Computes the list of values that are the intersection of all the arrays. Each value in the result
  734. * is present in each of the arrays.
  735. * @param arrays Array of arrays to compute the intersection of.
  736. * @return The intersection of elements within `arrays`.
  737. **/
  738. intersection<T>(...arrays: _.List<T>[]): T[];
  739. /**
  740. * Similar to without, but returns the values from array that are not present in the other arrays.
  741. * @param array Keeps values that are within `others`.
  742. * @param others The values to keep within `array`.
  743. * @return Copy of `array` with only `others` values.
  744. **/
  745. difference<T>(
  746. array: _.List<T>,
  747. ...others: _.List<T>[]): T[];
  748. /**
  749. * Produces a duplicate-free version of the array, using === to test object equality. If you know in
  750. * advance that the array is sorted, passing true for isSorted will run a much faster algorithm. If
  751. * you want to compute unique items based on a transformation, pass an iterator function.
  752. * @param array Array to remove duplicates from.
  753. * @param isSorted True if `array` is already sorted, optional, default = false.
  754. * @param iterator Transform the elements of `array` before comparisons for uniqueness.
  755. * @param context 'this' object in `iterator`, optional.
  756. * @return Copy of `array` where all elements are unique.
  757. **/
  758. uniq<T, TSort>(
  759. array: _.List<T>,
  760. isSorted?: boolean,
  761. iterator?: _.ListIterator<T, TSort>,
  762. context?: any): T[];
  763. /**
  764. * @see _.uniq
  765. **/
  766. uniq<T, TSort>(
  767. array: _.List<T>,
  768. iterator?: _.ListIterator<T, TSort>,
  769. context?: any): T[];
  770. /**
  771. * @see _.uniq
  772. **/
  773. unique<T, TSort>(
  774. array: _.List<T>,
  775. iterator?: _.ListIterator<T, TSort>,
  776. context?: any): T[];
  777. /**
  778. * @see _.uniq
  779. **/
  780. unique<T, TSort>(
  781. array: _.List<T>,
  782. isSorted?: boolean,
  783. iterator?: _.ListIterator<T, TSort>,
  784. context?: any): T[];
  785. /**
  786. * Merges together the values of each of the arrays with the values at the corresponding position.
  787. * Useful when you have separate data sources that are coordinated through matching array indexes.
  788. * If you're working with a matrix of nested arrays, zip.apply can transpose the matrix in a similar fashion.
  789. * @param arrays The arrays to merge/zip.
  790. * @return Zipped version of `arrays`.
  791. **/
  792. zip(...arrays: any[][]): any[][];
  793. /**
  794. * @see _.zip
  795. **/
  796. zip(...arrays: any[]): any[];
  797. /**
  798. * Converts arrays into objects. Pass either a single list of [key, value] pairs, or a
  799. * list of keys, and a list of values.
  800. * @param keys Key array.
  801. * @param values Value array.
  802. * @return An object containing the `keys` as properties and `values` as the property values.
  803. **/
  804. object<TResult extends {}>(
  805. keys: _.List<string>,
  806. values: _.List<any>): TResult;
  807. /**
  808. * Converts arrays into objects. Pass either a single list of [key, value] pairs, or a
  809. * list of keys, and a list of values.
  810. * @param keyValuePairs Array of [key, value] pairs.
  811. * @return An object containing the `keys` as properties and `values` as the property values.
  812. **/
  813. object<TResult extends {}>(...keyValuePairs: any[][]): TResult;
  814. /**
  815. * @see _.object
  816. **/
  817. object<TResult extends {}>(
  818. list: _.List<any>,
  819. values?: any): TResult;
  820. /**
  821. * Returns the index at which value can be found in the array, or -1 if value is not present in the array.
  822. * Uses the native indexOf function unless it's missing. If you're working with a large array, and you know
  823. * that the array is already sorted, pass true for isSorted to use a faster binary search ... or, pass a number
  824. * as the third argument in order to look for the first matching value in the array after the given index.
  825. * @param array The array to search for the index of `value`.
  826. * @param value The value to search for within `array`.
  827. * @param isSorted True if the array is already sorted, optional, default = false.
  828. * @return The index of `value` within `array`.
  829. **/
  830. indexOf<T>(
  831. array: _.List<T>,
  832. value: T,
  833. isSorted?: boolean): number;
  834. /**
  835. * @see _indexof
  836. **/
  837. indexOf<T>(
  838. array: _.List<T>,
  839. value: T,
  840. startFrom: number): number;
  841. /**
  842. * Returns the index of the last occurrence of value in the array, or -1 if value is not present. Uses the
  843. * native lastIndexOf function if possible. Pass fromIndex to start your search at a given index.
  844. * @param array The array to search for the last index of `value`.
  845. * @param value The value to search for within `array`.
  846. * @param from The starting index for the search, optional.
  847. * @return The index of the last occurrence of `value` within `array`.
  848. **/
  849. lastIndexOf<T>(
  850. array: _.List<T>,
  851. value: T,
  852. from?: number): number;
  853. /**
  854. * Uses a binary search to determine the index at which the value should be inserted into the list in order
  855. * to maintain the list's sorted order. If an iterator is passed, it will be used to compute the sort ranking
  856. * of each value, including the value you pass.
  857. * @param list The sorted list.
  858. * @param value The value to determine its index within `list`.
  859. * @param iterator Iterator to compute the sort ranking of each value, optional.
  860. * @return The index where `value` should be inserted into `list`.
  861. **/
  862. sortedIndex<T, TSort>(
  863. list: _.List<T>,
  864. value: T,
  865. iterator?: (x: T) => TSort, context?: any): number;
  866. /**
  867. * A function to create flexibly-numbered lists of integers, handy for each and map loops. start, if omitted,
  868. * defaults to 0; step defaults to 1. Returns a list of integers from start to stop, incremented (or decremented)
  869. * by step, exclusive.
  870. * @param start Start here.
  871. * @param stop Stop here.
  872. * @param step The number to count up by each iteration, optional, default = 1.
  873. * @return Array of numbers from `start` to `stop` with increments of `step`.
  874. **/
  875. range(
  876. start: number,
  877. stop: number,
  878. step?: number): number[];
  879. /**
  880. * @see _.range
  881. * @param stop Stop here.
  882. * @return Array of numbers from 0 to `stop` with increments of 1.
  883. * @note If start is not specified the implementation will never pull the step (step = arguments[2] || 0)
  884. **/
  885. range(stop: number): number[];
  886. /*************
  887. * Functions *
  888. *************/
  889. /**
  890. * Bind a function to an object, meaning that whenever the function is called, the value of this will
  891. * be the object. Optionally, bind arguments to the function to pre-fill them, also known as partial application.
  892. * @param func The function to bind `this` to `object`.
  893. * @param context The `this` pointer whenever `fn` is called.
  894. * @param arguments Additional arguments to pass to `fn` when called.
  895. * @return `fn` with `this` bound to `object`.
  896. **/
  897. bind(
  898. func: Function,
  899. context: any,
  900. ...arguments: any[]): () => any;
  901. /**
  902. * Binds a number of methods on the object, specified by methodNames, to be run in the context of that object
  903. * whenever they are invoked. Very handy for binding functions that are going to be used as event handlers,
  904. * which would otherwise be invoked with a fairly useless this. If no methodNames are provided, all of the
  905. * object's function properties will be bound to it.
  906. * @param object The object to bind the methods `methodName` to.
  907. * @param methodNames The methods to bind to `object`, optional and if not provided all of `object`'s
  908. * methods are bound.
  909. **/
  910. bindAll(
  911. object: any,
  912. ...methodNames: string[]): any;
  913. /**
  914. * Partially apply a function by filling in any number of its arguments, without changing its dynamic this value.
  915. * A close cousin of bind. You may pass _ in your list of arguments to specify an argument that should not be
  916. * pre-filled, but left open to supply at call-time.
  917. * @param fn Function to partially fill in arguments.
  918. * @param arguments The partial arguments.
  919. * @return `fn` with partially filled in arguments.
  920. **/
  921. partial(
  922. fn: Function,
  923. ...arguments: any[]): Function;
  924. /**
  925. * Memoizes a given function by caching the computed result. Useful for speeding up slow-running computations.
  926. * If passed an optional hashFunction, it will be used to compute the hash key for storing the result, based
  927. * on the arguments to the original function. The default hashFunction just uses the first argument to the
  928. * memoized function as the key.
  929. * @param fn Computationally expensive function that will now memoized results.
  930. * @param hashFn Hash function for storing the result of `fn`.
  931. * @return Memoized version of `fn`.
  932. **/
  933. memoize(
  934. fn: Function,
  935. hashFn?: (...args: any[]) => string): Function;
  936. /**
  937. * Much like setTimeout, invokes function after wait milliseconds. If you pass the optional arguments,
  938. * they will be forwarded on to the function when it is invoked.
  939. * @param func Function to delay `waitMS` amount of ms.
  940. * @param wait The amount of milliseconds to delay `fn`.
  941. * @arguments Additional arguments to pass to `fn`.
  942. **/
  943. delay(
  944. func: Function,
  945. wait: number,
  946. ...arguments: any[]): any;
  947. /**
  948. * @see _delay
  949. **/
  950. delay(
  951. func: Function,
  952. ...arguments: any[]): any;
  953. /**
  954. * Defers invoking the function until the current call stack has cleared, similar to using setTimeout
  955. * with a delay of 0. Useful for performing expensive computations or HTML rendering in chunks without
  956. * blocking the UI thread from updating. If you pass the optional arguments, they will be forwarded on
  957. * to the function when it is invoked.
  958. * @param fn The function to defer.
  959. * @param arguments Additional arguments to pass to `fn`.
  960. **/
  961. defer(
  962. fn: Function,
  963. ...arguments: any[]): void;
  964. /**
  965. * Creates and returns a new, throttled version of the passed function, that, when invoked repeatedly,
  966. * will only actually call the original function at most once per every wait milliseconds. Useful for
  967. * rate-limiting events that occur faster than you can keep up with.
  968. * By default, throttle will execute the function as soon as you call it for the first time, and,
  969. * if you call it again any number of times during the wait period, as soon as that period is over.
  970. * If you'd like to disable the leading-edge call, pass {leading: false}, and if you'd like to disable
  971. * the execution on the trailing-edge, pass {trailing: false}.
  972. * @param func Function to throttle `waitMS` ms.
  973. * @param wait The number of milliseconds to wait before `fn` can be invoked again.
  974. * @param options Allows for disabling execution of the throttled function on either the leading or trailing edge.
  975. * @return `fn` with a throttle of `wait`.
  976. **/
  977. throttle<T extends Function>(
  978. func: T,
  979. wait: number,
  980. options?: _.ThrottleSettings): T;
  981. /**
  982. * Creates and returns a new debounced version of the passed function that will postpone its execution
  983. * until after wait milliseconds have elapsed since the last time it was invoked. Useful for implementing
  984. * behavior that should only happen after the input has stopped arriving. For example: rendering a preview
  985. * of a Markdown comment, recalculating a layout after the window has stopped being resized, and so on.
  986. *
  987. * Pass true for the immediate parameter to cause debounce to trigger the function on the leading instead
  988. * of the trailing edge of the wait interval. Useful in circumstances like preventing accidental double
  989. *-clicks on a "submit" button from firing a second time.
  990. * @param fn Function to debounce `waitMS` ms.
  991. * @param wait The number of milliseconds to wait before `fn` can be invoked again.
  992. * @param immediate True if `fn` should be invoked on the leading edge of `waitMS` instead of the trailing edge.
  993. * @return Debounced version of `fn` that waits `wait` ms when invoked.
  994. **/
  995. debounce<T extends Function>(
  996. fn: T,
  997. wait: number,
  998. immediate?: boolean): T;
  999. /**
  1000. * Creates a version of the function that can only be called one time. Repeated calls to the modified
  1001. * function will have no effect, returning the value from the original call. Useful for initialization
  1002. * functions, instead of having to set a boolean flag and then check it later.
  1003. * @param fn Function to only execute once.
  1004. * @return Copy of `fn` that can only be invoked once.
  1005. **/
  1006. once<T extends Function>(fn: T): T;
  1007. /**
  1008. * Creates a version of the function that will only be run after first being called count times. Useful
  1009. * for grouping asynchronous responses, where you want to be sure that all the async calls have finished,
  1010. * before proceeding.
  1011. * @param number count Number of times to be called before actually executing.
  1012. * @param Function fn The function to defer execution `count` times.
  1013. * @return Copy of `fn` that will not execute until it is invoked `count` times.
  1014. **/
  1015. after(
  1016. count: number,
  1017. fn: Function): Function;
  1018. /**
  1019. * Creates a version of the function that can be called no more than count times. The result of
  1020. * the last function call is memoized and returned when count has been reached.
  1021. * @param number count The maxmimum number of times the function can be called.
  1022. * @param Function fn The function to limit the number of times it can be called.
  1023. * @return Copy of `fn` that can only be called `count` times.
  1024. **/
  1025. before(
  1026. count: number,
  1027. fn: Function): Function;
  1028. /**
  1029. * Wraps the first function inside of the wrapper function, passing it as the first argument. This allows
  1030. * the wrapper to execute code before and after the function runs, adjust the arguments, and execute it
  1031. * conditionally.
  1032. * @param fn Function to wrap.
  1033. * @param wrapper The function that will wrap `fn`.
  1034. * @return Wrapped version of `fn.
  1035. **/
  1036. wrap(
  1037. fn: Function,
  1038. wrapper: (fn: Function, ...args: any[]) => any): Function;
  1039. /**
  1040. * Returns a negated version of the pass-in predicate.
  1041. * @param Function predicate
  1042. * @return boolean
  1043. **/
  1044. negate(predicate: Function): boolean;
  1045. /**
  1046. * Returns the composition of a list of functions, where each function consumes the return value of the
  1047. * function that follows. In math terms, composing the functions f(), g(), and h() produces f(g(h())).
  1048. * @param functions List of functions to compose.
  1049. * @return Composition of `functions`.
  1050. **/
  1051. compose(...functions: Function[]): Function;
  1052. /**********
  1053. * Objects *
  1054. ***********/
  1055. /**
  1056. * Retrieve all the names of the object's properties.
  1057. * @param object Retrieve the key or property names from this object.
  1058. * @return List of all the property names on `object`.
  1059. **/
  1060. keys(object: any): string[];
  1061. /**
  1062. * Return all of the values of the object's properties.
  1063. * @param object Retrieve the values of all the properties on this object.
  1064. * @return List of all the values on `object`.
  1065. **/
  1066. values(object: any): any[];
  1067. /**
  1068. * Like map, but for objects. Transform the value of each property in turn.
  1069. * @param object The object to transform
  1070. * @param iteratee The function that transforms property values
  1071. * @param context The optional context (value of `this`) to bind to
  1072. * @return a new _.Dictionary of property values
  1073. */
  1074. mapObject<T, U>(object: _.Dictionary<T>, iteratee: (val: T, key: string, object: _.Dictionary<T>) => U, context?: any): _.Dictionary<U>;
  1075. /**
  1076. * Like map, but for objects. Transform the value of each property in turn.
  1077. * @param object The object to transform
  1078. * @param iteratee The function that tranforms property values
  1079. * @param context The optional context (value of `this`) to bind to
  1080. */
  1081. mapObject<T>(object: any, iteratee: (val: any, key: string, object: any) => T, context?: any): _.Dictionary<T>;
  1082. /**
  1083. * Like map, but for objects. Retrieves a property from each entry in the object, as if by _.property
  1084. * @param object The object to transform
  1085. * @param iteratee The property name to retrieve
  1086. * @param context The optional context (value of `this`) to bind to
  1087. */
  1088. mapObject(object: any, iteratee: string, context?: any): _.Dictionary<any>;
  1089. /**
  1090. * Convert an object into a list of [key, value] pairs.
  1091. * @param object Convert this object to a list of [key, value] pairs.
  1092. * @return List of [key, value] pairs on `object`.
  1093. **/
  1094. pairs(object: any): any[][];
  1095. /**
  1096. * Returns a copy of the object where the keys have become the values and the values the keys.
  1097. * For this to work, all of your object's values should be unique and string serializable.
  1098. * @param object Object to invert key/value pairs.
  1099. * @return An inverted key/value paired version of `object`.
  1100. **/
  1101. invert(object: any): any;
  1102. /**
  1103. * Returns a sorted list of the names of every method in an object - that is to say,
  1104. * the name of every function property of the object.
  1105. * @param object Object to pluck all function property names from.
  1106. * @return List of all the function names on `object`.
  1107. **/
  1108. functions(object: any): string[];
  1109. /**
  1110. * @see _functions
  1111. **/
  1112. methods(object: any): string[];
  1113. /**
  1114. * Copy all of the properties in the source objects over to the destination object, and return
  1115. * the destination object. It's in-order, so the last source will override properties of the
  1116. * same name in previous arguments.
  1117. * @param destination Object to extend all the properties from `sources`.
  1118. * @param sources Extends `destination` with all properties from these source objects.
  1119. * @return `destination` extended with all the properties from the `sources` objects.
  1120. **/
  1121. extend(
  1122. destination: any,
  1123. ...sources: any[]): any;
  1124. /**
  1125. * Like extend, but only copies own properties over to the destination object. (alias: assign)
  1126. */
  1127. extendOwn(
  1128. destination: any,
  1129. ...source: any[]): any;
  1130. /**
  1131. * Like extend, but only copies own properties over to the destination object. (alias: extendOwn)
  1132. */
  1133. assign(
  1134. destination: any,
  1135. ...source: any[]): any;
  1136. /**
  1137. * Return a copy of the object, filtered to only have values for the whitelisted keys
  1138. * (or array of valid keys).
  1139. * @param object Object to strip unwanted key/value pairs.
  1140. * @keys The key/value pairs to keep on `object`.
  1141. * @return Copy of `object` with only the `keys` properties.
  1142. **/
  1143. pick(
  1144. object: any,
  1145. ...keys: any[]): any;
  1146. /**
  1147. * @see _.pick
  1148. **/
  1149. pick(
  1150. object: any,
  1151. fn: (value: any, key: any, object: any) => any): any;
  1152. /**
  1153. * Return a copy of the object, filtered to omit the blacklisted keys (or array of keys).
  1154. * @param object Object to strip unwanted key/value pairs.
  1155. * @param keys The key/value pairs to remove on `object`.
  1156. * @return Copy of `object` without the `keys` properties.
  1157. **/
  1158. omit(
  1159. object: any,
  1160. ...keys: string[]): any;
  1161. /**
  1162. * @see _.omit
  1163. **/
  1164. omit(
  1165. object: any,
  1166. keys: string[]): any;
  1167. /**
  1168. * @see _.omit
  1169. **/
  1170. omit(
  1171. object: any,
  1172. iteratee: Function): any;
  1173. /**
  1174. * Fill in null and undefined properties in object with values from the defaults objects,
  1175. * and return the object. As soon as the property is filled, further defaults will have no effect.
  1176. * @param object Fill this object with default values.
  1177. * @param defaults The default values to add to `object`.
  1178. * @return `object` with added `defaults` values.
  1179. **/
  1180. defaults(
  1181. object: any,
  1182. ...defaults: any[]): any;
  1183. /**
  1184. * Create a shallow-copied clone of the object.
  1185. * Any nested objects or arrays will be copied by reference, not duplicated.
  1186. * @param object Object to clone.
  1187. * @return Copy of `object`.
  1188. **/
  1189. clone<T>(object: T): T;
  1190. /**
  1191. * Invokes interceptor with the object, and then returns object. The primary purpose of this method
  1192. * is to "tap into" a method chain, in order to perform operations on intermediate results within the chain.
  1193. * @param object Argument to `interceptor`.
  1194. * @param intercepter The function to modify `object` before continuing the method chain.
  1195. * @return Modified `object`.
  1196. **/
  1197. tap<T>(object: T, intercepter: Function): T;
  1198. /**
  1199. * Does the object contain the given key? Identical to object.hasOwnProperty(key), but uses a safe
  1200. * reference to the hasOwnProperty function, in case it's been overridden accidentally.
  1201. * @param object Object to check for `key`.
  1202. * @param key The key to check for on `object`.
  1203. * @return True if `key` is a property on `object`, otherwise false.
  1204. **/
  1205. has(object: any, key: string): boolean;
  1206. /**
  1207. * Returns a predicate function that will tell you if a passed in object contains all of the key/value properties present in attrs.
  1208. * @param attrs Object with key values pair
  1209. * @return Predicate function
  1210. **/
  1211. matches<T, TResult>(attrs: T): _.ListIterator<T, TResult>;
  1212. /**
  1213. * Returns a function that will itself return the key property of any passed-in object.
  1214. * @param key Property of the object.
  1215. * @return Function which accept an object an returns the value of key in that object.
  1216. **/
  1217. property(key: string): (object: Object) => any;
  1218. /**
  1219. * Performs an optimized deep comparison between the two objects,
  1220. * to determine if they should be considered equal.
  1221. * @param object Compare to `other`.
  1222. * @param other Compare to `object`.
  1223. * @return True if `object` is equal to `other`.
  1224. **/
  1225. isEqual(object: any, other: any): boolean;
  1226. /**
  1227. * Returns true if object contains no values.
  1228. * @param object Check if this object has no properties or values.
  1229. * @return True if `object` is empty.
  1230. **/
  1231. isEmpty(object: any): boolean;
  1232. /**
  1233. * Returns true if object is a DOM element.
  1234. * @param object Check if this object is a DOM element.
  1235. * @return True if `object` is a DOM element, otherwise false.
  1236. **/
  1237. isElement(object: any): boolean;
  1238. /**
  1239. * Returns true if object is an Array.
  1240. * @param object Check if this object is an Array.
  1241. * @return True if `object` is an Array, otherwise false.
  1242. **/
  1243. isArray(object: any): boolean;
  1244. /**
  1245. * Returns true if value is an Object. Note that JavaScript arrays and functions are objects,
  1246. * while (normal) strings and numbers are not.
  1247. * @param object Check if this object is an Object.
  1248. * @return True of `object` is an Object, otherwise false.
  1249. **/
  1250. isObject(object: any): boolean;
  1251. /**
  1252. * Returns true if object is an Arguments object.
  1253. * @param object Check if this object is an Arguments object.
  1254. * @return True if `object` is an Arguments object, otherwise false.
  1255. **/
  1256. isArguments(object: any): boolean;
  1257. /**
  1258. * Returns true if object is a Function.
  1259. * @param object Check if this object is a Function.
  1260. * @return True if `object` is a Function, otherwise false.
  1261. **/
  1262. isFunction(object: any): boolean;
  1263. /**
  1264. * Returns true if object is a String.
  1265. * @param object Check if this object is a String.
  1266. * @return True if `object` is a String, otherwise false.
  1267. **/
  1268. isString(object: any): boolean;
  1269. /**
  1270. * Returns true if object is a Number (including NaN).
  1271. * @param object Check if this object is a Number.
  1272. * @return True if `object` is a Number, otherwise false.
  1273. **/
  1274. isNumber(object: any): boolean;
  1275. /**
  1276. * Returns true if object is a finite Number.
  1277. * @param object Check if this object is a finite Number.
  1278. * @return True if `object` is a finite Number.
  1279. **/
  1280. isFinite(object: any): boolean;
  1281. /**
  1282. * Returns true if object is either true or false.
  1283. * @param object Check if this object is a bool.
  1284. * @return True if `object` is a bool, otherwise false.
  1285. **/
  1286. isBoolean(object: any): boolean;
  1287. /**
  1288. * Returns true if object is a Date.
  1289. * @param object Check if this object is a Date.
  1290. * @return True if `object` is a Date, otherwise false.
  1291. **/
  1292. isDate(object: any): boolean;
  1293. /**
  1294. * Returns true if object is a RegExp.
  1295. * @param object Check if this object is a RegExp.
  1296. * @return True if `object` is a RegExp, otherwise false.
  1297. **/
  1298. isRegExp(object: any): boolean;
  1299. /**
  1300. * Returns true if object is NaN.
  1301. * Note: this is not the same as the native isNaN function,
  1302. * which will also return true if the variable is undefined.
  1303. * @param object Check if this object is NaN.
  1304. * @return True if `object` is NaN, otherwise false.
  1305. **/
  1306. isNaN(object: any): boolean;
  1307. /**
  1308. * Returns true if the value of object is null.
  1309. * @param object Check if this object is null.
  1310. * @return True if `object` is null, otherwise false.
  1311. **/
  1312. isNull(object: any): boolean;
  1313. /**
  1314. * Returns true if value is undefined.
  1315. * @param object Check if this object is undefined.
  1316. * @return True if `object` is undefined, otherwise false.
  1317. **/
  1318. isUndefined(value: any): boolean;
  1319. /* *********
  1320. * Utility *
  1321. ********** */
  1322. /**
  1323. * Give control of the "_" variable back to its previous owner.
  1324. * Returns a reference to the Underscore object.
  1325. * @return Underscore object reference.
  1326. **/
  1327. noConflict(): any;
  1328. /**
  1329. * Returns the same value that is used as the argument. In math: f(x) = x
  1330. * This function looks useless, but is used throughout Underscore as a default iterator.
  1331. * @param value Identity of this object.
  1332. * @return `value`.
  1333. **/
  1334. identity<T>(value: T): T;
  1335. /**
  1336. * Creates a function that returns the same value that is used as the argument of _.constant
  1337. * @param value Identity of this object.
  1338. * @return Function that return value.
  1339. **/
  1340. constant<T>(value: T): () => T;
  1341. /**
  1342. * Returns undefined irrespective of the arguments passed to it. Useful as the default
  1343. * for optional callback arguments.
  1344. * Note there is no way to indicate a 'undefined' return, so it is currently typed as void.
  1345. * @return undefined
  1346. **/
  1347. noop(): void;
  1348. /**
  1349. * Invokes the given iterator function n times.
  1350. * Each invocation of iterator is called with an index argument
  1351. * @param n Number of times to invoke `iterator`.
  1352. * @param iterator Function iterator to invoke `n` times.
  1353. * @param context `this` object in `iterator`, optional.
  1354. **/
  1355. times<TResult>(n: number, iterator: (n: number) => TResult, context?: any): TResult[];
  1356. /**
  1357. * Returns a random integer between min and max, inclusive. If you only pass one argument,
  1358. * it will return a number between 0 and that number.
  1359. * @param max The maximum random number.
  1360. * @return A random number between 0 and `max`.
  1361. **/
  1362. random(max: number): number;
  1363. /**
  1364. * @see _.random
  1365. * @param min The minimum random number.
  1366. * @return A random number between `min` and `max`.
  1367. **/
  1368. random(min: number, max: number): number;
  1369. /**
  1370. * Allows you to extend Underscore with your own utility functions. Pass a hash of
  1371. * {name: function} definitions to have your functions added to the Underscore object,
  1372. * as well as the OOP wrapper.
  1373. * @param object Mixin object containing key/function pairs to add to the Underscore object.
  1374. **/
  1375. mixin(object: any): void;
  1376. /**
  1377. * A mostly-internal function to generate callbacks that can be applied to each element
  1378. * in a collection, returning the desired result -- either identity, an arbitrary callback,
  1379. * a property matcher, or a propetery accessor.
  1380. * @param string|Function|Object value The value to iterate over, usually the key.
  1381. * @param any context
  1382. * @param number argCount
  1383. * @return Callback that can be applied to each element in a collection.
  1384. **/
  1385. iteratee(value: string): Function;
  1386. iteratee(value: Function, context?: any, argCount?: number): Function;
  1387. iteratee(value: Object): Function;
  1388. /**
  1389. * Generate a globally-unique id for client-side models or DOM elements that need one.
  1390. * If prefix is passed, the id will be appended to it. Without prefix, returns an integer.
  1391. * @param prefix A prefix string to start