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