PageRenderTime 31ms CodeModel.GetById 32ms RepoModel.GetById 1ms app.codeStats 0ms

/src/main/resources/front/js/typedefs/underscore-typed-1.4.d.ts

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