├── .gitignore ├── .vscode ├── launch.json ├── settings.json └── tasks.json ├── .vscodeignore ├── CHANGELOG.md ├── LICENSE.txt ├── README.md ├── extension.ts ├── images ├── MDToolsIcon.svg ├── icon.jpg └── mdtools1.gif ├── package.json ├── thirdpartynotices.txt ├── tsconfig.json └── typings ├── underscore.string └── underscore.string.d.ts ├── underscore └── underscore.d.ts └── vscode-typings.d.ts /.gitignore: -------------------------------------------------------------------------------- 1 | out 2 | node_modules 3 | *.vsix -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that compiles the extension and then opens it inside a new window 2 | { 3 | "version": "0.1.0", 4 | "configurations": [ 5 | { 6 | "name": "Launch Extension", 7 | "type": "extensionHost", 8 | "runtimeExecutable": "${execPath}", 9 | "args": ["--extensionDevelopmentPath=${workspaceRoot}" ], 10 | "stopOnEntry": false, 11 | "sourceMaps": true, 12 | "outDir": "${workspaceRoot}/out", 13 | "preLaunchTask": "npm" 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Place your settings in this file to overwrite default and user settings. 2 | { 3 | "files.exclude": { 4 | "out": false // set this to true to hide the "out" folder with the compiled JS files 5 | }, 6 | "typescript.tsdk": "./node_modules/typescript/lib" // we want to use the TS server from our node_modules folder to control its version 7 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | // Available variables which can be used inside of strings. 2 | // ${workspaceRoot}: the root folder of the team 3 | // ${file}: the current opened file 4 | // ${fileBasename}: the current opened file's basename 5 | // ${fileDirname}: the current opened file's dirname 6 | // ${fileExtname}: the current opened file's extension 7 | // ${cwd}: the current working directory of the spawned process 8 | 9 | // A task runner that calls a custom npm script that compiles the extension. 10 | { 11 | "version": "0.1.0", 12 | 13 | // we want to run npm 14 | "command": "npm", 15 | 16 | // the command is a shell script 17 | "isShellCommand": true, 18 | 19 | // show the output window only if unrecognized errors occur. 20 | "showOutput": "silent", 21 | 22 | // we run the custom script "compile" as defined in package.json 23 | "args": ["run", "compile"], 24 | 25 | // The tsc compiler is started in watching mode 26 | "isWatching": true, 27 | 28 | // use the standard tsc in watch mode problem matcher to find compile problems in the output. 29 | "problemMatcher": "$tsc-watch" 30 | } -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | typings/** 3 | **/*.ts 4 | .gitignore 5 | tsconfig.json 6 | vsc-extension-quickstart.md 7 | *.vsix 8 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Updates 2 | 3 | ## 1.0.1 4 | 5 | * Accepted two PRs thank you [@alefragnani](https://github.com/alefragnani) to fix issues on empty file operations and to support additional filetypes. 6 | 7 | ## 1.0.0 8 | 9 | * Fixed some multi selection bugs 10 | * fix: ASCII Art, toUpper, ToLower all now support multi-selection 11 | * Added in a few more options 12 | * Slugify 13 | * Camelize -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) Microsoft Corporation 2 | 3 | All rights reserved. 4 | 5 | MIT License 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation 8 | files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, 9 | modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software 10 | is furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 15 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 16 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 17 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Functionality 2 | 3 | This is an example of how to extend [VS Code](https://github.com/Microsoft/vscode) with some useful text manipulation tools. This extension works for all file types. 4 | 5 | These include: 6 | 7 | * Common casing operations e.g. toUpper, ToLower, SwapCase, Reverse and more 8 | * HTML encoding and Decoding 9 | * ASCII Art 10 | 11 | # Install 12 | 13 | Open up VS Code and hit `F1` and type `ext` select Install Extension and type `mdtools` hit enter and reload window to enable. 14 | 15 | ![install and work](images/mdtools1.gif) 16 | 17 | 18 | # Update a selection 19 | 20 | The extension is activated for all file types, and you open up a menu of commands by pressing `Alt+T`. Multi selection is supported for all commands. If you select ASCII Art you will get a secondary menu where you can choose the font. 21 | 22 | 23 | # Known Issues 24 | 25 | Here are a few common issues. 26 | 27 | * The selection zone post edit can be mis-mapped. 28 | 29 | -------------------------------------------------------------------------------- /extension.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import * as vscode from 'vscode'; 4 | import Window = vscode.window; 5 | import QuickPickItem = vscode.QuickPickItem; 6 | import QuickPickOptions = vscode.QuickPickOptions; 7 | import Document = vscode.TextDocument; 8 | import Position = vscode.Position; 9 | import Range = vscode.Range; 10 | import Selection = vscode.Selection; 11 | import TextDocument = vscode.TextDocument; 12 | import TextEditor = vscode.TextEditor; 13 | //import InputBoxOptions = InputBoxOptions; 14 | 15 | var figlet = require('figlet'); 16 | import us = require('underscore.string'); 17 | 18 | export function activate() { 19 | console.log('Congratulations, your extension "TextTools" is now active!'); 20 | vscode.commands.registerCommand('extension.textFunctions', textFunctions); 21 | } 22 | 23 | // String Functions Helper////////////////////////////// 24 | function toUpper(e: TextEditor, d: TextDocument, sel: Selection[]) { 25 | e.edit(function (edit) { 26 | // itterate through the selections and convert all text to Upper 27 | for (var x = 0; x < sel.length; x++) { 28 | let txt: string = d.getText(new Range(sel[x].start, sel[x].end)); 29 | edit.replace(sel[x], txt.toUpperCase()); 30 | } 31 | }); 32 | } 33 | 34 | function toLower(e: TextEditor, d: TextDocument, sel: Selection[]) { 35 | e.edit(function (edit) { 36 | // itterate through the selections and convert all text to Lower 37 | for (var x = 0; x < sel.length; x++) { 38 | let txt: string = d.getText(new Range(sel[x].start, sel[x].end)); 39 | edit.replace(sel[x], txt.toLowerCase()); 40 | } 41 | }); 42 | 43 | } 44 | 45 | // This function takes a callback function for the text formatting 'formatCB', 46 | // if there are any args pass an array as 'argsCB' 47 | function processSelection(e: TextEditor, d: TextDocument, sel: Selection[], formatCB, argsCB) { 48 | var replaceRanges: Selection[] = []; 49 | e.edit(function (edit) { 50 | // itterate through the selections 51 | for (var x = 0; x < sel.length; x++) { 52 | let txt: string = d.getText(new Range(sel[x].start, sel[x].end)); 53 | if (argsCB.length > 0) { 54 | // in the case of figlet the params are test to change and font so this is hard coded 55 | // the idea of the array of parameters is to allow for a more general approach in the future 56 | txt = formatCB.apply(this, [txt, argsCB[0]]); 57 | } else { 58 | txt = formatCB(txt); 59 | } 60 | 61 | //replace the txt in the current select and work out any range adjustments 62 | edit.replace(sel[x], txt); 63 | let startPos: Position = new Position(sel[x].start.line, sel[x].start.character); 64 | let endPos: Position = new Position(sel[x].start.line + txt.split(/\r\n|\r|\n/).length - 1, sel[x].start.character + txt.length); 65 | replaceRanges.push(new Selection(startPos, endPos)); 66 | } 67 | }); 68 | e.selections = replaceRanges; 69 | } 70 | 71 | // Main menu ///////////////////////////////////// 72 | function textFunctions() { 73 | 74 | if (!vscode.window.activeTextEditor) { 75 | vscode.window.showInformationMessage('Open a file first to manipulate text selections'); 76 | return; 77 | } 78 | 79 | var opts: QuickPickOptions = { matchOnDescription: true, placeHolder: "What do you want to do to the selection(s)?" }; 80 | var items: QuickPickItem[] = []; 81 | 82 | items.push({ label: "toUpper", description: "Convert [aBc] to [ABC]" }); 83 | items.push({ label: "toLower", description: "Convert [aBc] to [abc]" }); 84 | items.push({ label: "swapCase", description: "Convert [aBc] to [AbC]" }); 85 | items.push({ label: "Titleize", description: "Convert [hello MD tools] to [Hello MD Tools]" }); 86 | items.push({ label: "Camelize", description: "Convert [hello MD-tools] to [HelloMDTools]" }); 87 | items.push({ label: "Clean String", description: "Convert [hello......world] to [hello world]" }); 88 | items.push({ label: "Reverse", description: "Convert [hello world] to [world hello]" }); 89 | items.push({ label: "Escape HTML", description: "Convert [
hello] to [<div>hello]" }); 90 | items.push({ label: "UnEscape HTML", description: "Convert [<div>hello] to [
hello]" }); 91 | items.push({ label: "Slugify", description: "Convert [txt for an URL] to [txt-for-an-url]" }); 92 | items.push({ label: "ASCII Art", description: "Convert [hello] to ASCII Art" }); 93 | 94 | Window.showQuickPick(items).then((selection) => { 95 | if (!selection) { 96 | return; 97 | } 98 | let e = Window.activeTextEditor; 99 | let d = e.document; 100 | let sel = e.selections; 101 | 102 | switch (selection.label) { 103 | case "toUpper": 104 | toUpper(e, d, sel); 105 | break; 106 | case "toLower": 107 | toLower(e, d, sel); 108 | break; 109 | case "swapCase": 110 | processSelection(e, d, sel, us.swapCase, []); 111 | break; 112 | case "Titleize": 113 | processSelection(e, d, sel, us.titleize, []); 114 | break; 115 | case "Clean String": 116 | processSelection(e, d, sel, us.clean, []); 117 | break; 118 | case "Reverse": 119 | processSelection(e, d, sel, us.reverse, []); 120 | break; 121 | case "Escape HTML": 122 | processSelection(e, d, sel, us.escapeHTML, []); 123 | break; 124 | case "UnEscape HTML": 125 | processSelection(e, d, sel, us.unescapeHTML, []); 126 | break; 127 | case "Camelize": 128 | processSelection(e, d, sel, us.camelize, []); 129 | break; 130 | case "Slugify": 131 | processSelection(e, d, sel, us.slugify, []); 132 | break; 133 | case "ASCII Art": 134 | // build a full list of the fonts for the drop down 135 | items = []; 136 | figlet.fontsSync().forEach(function (font) { 137 | items.push({ label: font, description: "User the " + font + " font" }); 138 | }, this); 139 | 140 | Window.showQuickPick(items).then(function (selection) { 141 | if (!selection) { 142 | return; 143 | } 144 | processSelection(e, d, sel, figlet.textSync, [selection.label]); 145 | }); 146 | break; 147 | default: 148 | console.log("hum this should not have happend - no selection") 149 | break; 150 | } 151 | }); 152 | } 153 | -------------------------------------------------------------------------------- /images/MDToolsIcon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 13 | 14 | 15 | 16 | 17 | 18 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 28 | 30 | 32 | 34 | 37 | 40 | 43 | 46 | 49 | 52 | 55 | 58 | 61 | 64 | 67 | 70 | 73 | 76 | 79 | 82 | 85 | 87 | 89 | 92 | 95 | 98 | 101 | 104 | 107 | 110 | 113 | 115 | 118 | 121 | 123 | 126 | 127 | 128 | 130 | 132 | 134 | 136 | 138 | 141 | 143 | 145 | 148 | 151 | 154 | 157 | 160 | 163 | 166 | 169 | 172 | 175 | 178 | 181 | 184 | 187 | 190 | 193 | 196 | 199 | 202 | 205 | 208 | 210 | 213 | 216 | 219 | 222 | 223 | 224 | 225 | 226 | 227 | 231 | 236 | 241 | 244 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | -------------------------------------------------------------------------------- /images/icon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-MDTools/1dfb269e85f4edc490c5f7b77f795660e0455f06/images/icon.jpg -------------------------------------------------------------------------------- /images/mdtools1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-MDTools/1dfb269e85f4edc490c5f7b77f795660e0455f06/images/mdtools1.gif -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "MDTools", 3 | "description": "Text replacement functions e.g. change case, reverse and ASCII Art for all file types.", 4 | "version": "1.0.1", 5 | "publisher": "seanmcbreen", 6 | "categories":[ 7 | "Other" 8 | ], 9 | "license":"SEE LICENSE IN LICENSE.txt", 10 | "icon": "images/MDToolsIcon.svg", 11 | "bugs": { 12 | "url": "https://github.com/Microsoft/vscode-MDTools/issues" 13 | }, 14 | "homepage": "https://github.com/Microsoft/vscode-MDTools/blob/master/README.md", 15 | "repository": { 16 | "type": "git", 17 | "url": "https://github.com/Microsoft/vscode-MDTools.git" 18 | }, 19 | "galleryBanner" : { 20 | "color": "#5c2d91", 21 | "theme" : "dark" 22 | }, 23 | "activationEvents": [ 24 | "onCommand:extension.textFunctions" 25 | ], 26 | "engines": { 27 | "vscode": "^1.0.0" 28 | }, 29 | "main": "./out/extension", 30 | "contributes": { 31 | "commands": [ 32 | { 33 | "command": "extension.textFunctions", 34 | "title": "Text Functions", 35 | "description": "Text functions on selections" 36 | } 37 | ], 38 | "keybindings": [ 39 | { 40 | "command": "extension.textFunctions", 41 | "key": "Alt+T" 42 | } 43 | ] 44 | }, 45 | "scripts": { 46 | "vscode:prepublish": "node ./node_modules/vscode/bin/compile", 47 | "compile": "node ./node_modules/vscode/bin/compile -watch -p ./", 48 | "postinstall": "node ./node_modules/vscode/bin/install" 49 | }, 50 | "dependencies": { 51 | "underscore.string": "^3.2.2", 52 | "figlet": "^1.1.1" 53 | }, 54 | "devDependencies": { 55 | "vscode": "^0.11.0", 56 | "typescript": "^1.8.5" 57 | } 58 | } -------------------------------------------------------------------------------- /thirdpartynotices.txt: -------------------------------------------------------------------------------- 1 | THIRD-PARTY SOFTWARE NOTICES AND INFORMATION 2 | For Microsoft vscode-MDTools 3 | 4 | This project incorporates material from the projects listed below. The original copyright notice 5 | and the license under which Microsoft received such material are set out below. Microsoft reserves 6 | all other rights not expressly granted, whether by implication, estoppel or otherwise. 7 | 8 | 9 | 1. underscore.string version 3.2.2 (https://github.com/epeli/underscore.string) 10 | 11 | The MIT License 12 | 13 | Copyright (c) 2011 Esa-Matti Suuronen esa-matti@suuronen.org 14 | 15 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | 21 | 22 | 2. figlet 1.1.1 (https://github.com/patorjk/figlet.js) 23 | 24 | The MIT License (MIT) 25 | 26 | Copyright (C) 2014-present Patrick Gillespie and other contributors 27 | 28 | Permission is hereby granted, free of charge, to any person obtaining a copy 29 | of this software and associated documentation files (the "Software"), to deal 30 | in the Software without restriction, including without limitation the rights 31 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 32 | copies of the Software, and to permit persons to whom the Software is 33 | furnished to do so, subject to the following conditions: 34 | 35 | The above copyright notice and this permission notice shall be included in 36 | all copies or substantial portions of the Software. 37 | 38 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 39 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 40 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 41 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 42 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 43 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 44 | THE SOFTWARE. -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es5", 5 | "outDir": "out", 6 | "noLib": true, 7 | "sourceMap": true, 8 | "rootDir": "." 9 | }, 10 | "exclude": [ 11 | "node_modules" 12 | ] 13 | } -------------------------------------------------------------------------------- /typings/underscore.string/underscore.string.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for underscore.string 2 | // Project: https://github.com/epeli/underscore.string 3 | // Definitions by: Ry Racherbaumer 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | /// 7 | 8 | interface UnderscoreStatic { 9 | str: UnderscoreStringStatic; 10 | string: UnderscoreStringStatic; 11 | } 12 | 13 | declare var s : UnderscoreStringStatic; 14 | 15 | interface UnderscoreStringStatic extends UnderscoreStringStaticExports { 16 | /** 17 | * Tests if string contains a substring. 18 | * ('foobar', 'ob') => true 19 | * @param str 20 | * @param needle 21 | */ 22 | include(str: string, needle: string): boolean; 23 | 24 | /** 25 | * Tests if string contains a substring. 26 | * ('foobar', 'ob') => true 27 | * @param str 28 | * @param needle 29 | */ 30 | contains(str: string, needle: string): boolean; 31 | 32 | /** 33 | * Return reversed string. 34 | * ('foobar') => 'raboof' 35 | * @param str 36 | */ 37 | reverse(str: string): string; 38 | } 39 | 40 | /** 41 | * Functions exported for mixing with underscore object. 42 | * 43 | * Usage: 44 | * _.mixin(_.string.exports()); 45 | * interface UnderscoreStatic extends UnderscoreStringStaticExports { } 46 | */ 47 | interface UnderscoreStringStaticExports { 48 | 49 | exports(): UnderscoreStringStaticExports; 50 | 51 | /** 52 | * Determine if a string is 'blank.' 53 | * @param str 54 | */ 55 | isBlank(str: string): boolean; 56 | 57 | /** 58 | * Removes all html tags from string. 59 | * @param str 60 | */ 61 | stripTags(str: string): string; 62 | 63 | /** 64 | * Converts first letter of the string to uppercase. 65 | * ('foo Bar') => 'Foo Bar' 66 | * @param str 67 | */ 68 | capitalize(str: string): string; 69 | 70 | /** 71 | * Chop a string into pieces. 72 | * ('whitespace', 3) => ['whi','tes','pac','e'] 73 | * @param str String to chop 74 | * @param step Size of the pieces 75 | */ 76 | chop(str: string, step: number): any[]; 77 | 78 | /** 79 | * Compress some whitespaces to one. 80 | * (' foo bar ') => 'foo bar' 81 | * @param str 82 | */ 83 | clean(str: string): string; 84 | 85 | /** 86 | * Count occurences of a sub string. 87 | * ('Hello world', 'l') => 3 88 | * @param str 89 | * @param substr 90 | */ 91 | count(str: string, substr: string): number; 92 | 93 | /** 94 | * Convert string to an array of characters. 95 | * ('Hello') => ['H','e','l','l','o'] 96 | * @param str 97 | */ 98 | chars(str: string): any[]; 99 | 100 | /** 101 | * Returns a copy of the string in which all the case-based characters have had their case swapped. 102 | * ('hELLO') => 'Hello' 103 | * @param str 104 | */ 105 | swapCase(str: string): string; 106 | 107 | /** 108 | * Converts HTML special characters to their entity equivalents. 109 | * ('
Blah blah blah
') => '<div>Blah blah blah</div>' 110 | * @param str 111 | */ 112 | escapeHTML(str: string): string; 113 | 114 | /** 115 | * Converts entity characters to HTML equivalents. 116 | * ('<div>Blah blah blah</div>') => '
Blah blah blah
' 117 | * @param str 118 | */ 119 | unescapeHTML(str: string): string; 120 | 121 | /** 122 | * Escape a string for use in a regular expression. 123 | * @param str 124 | */ 125 | escapeRegExp(str: string): string; 126 | 127 | /** 128 | * Splice a string like an array. 129 | * @param str 130 | * @param i 131 | * @param howmany 132 | * @param substr 133 | */ 134 | splice(str: string, i: number, howmany: number, substr?: string): string; 135 | 136 | /** 137 | * Insert a string at index. 138 | * @param str 139 | * @param i 140 | * @param substr 141 | */ 142 | insert(str: string, i: number, substr: string): string; 143 | 144 | /** 145 | * Joins strings together with given separator. 146 | * (' ', 'foo', 'bar') => 'foo bar' 147 | * @param separator 148 | * @param args 149 | */ 150 | join(separator: string, ...args: string[]): string; 151 | 152 | /** 153 | * Split string by newlines character. 154 | * ('Hello\nWorld') => ['Hello', 'World'] 155 | * @param str 156 | */ 157 | lines(str: string): any[]; 158 | 159 | /** 160 | * Checks if string starts with another string. 161 | * ('image.gif', 'image') => true 162 | * @param str 163 | * @param starts 164 | */ 165 | startsWith(str: string, starts: string): boolean; 166 | 167 | /** 168 | * Checks if string ends with another string. 169 | * ('image.gif', 'gif') => true 170 | * @param value 171 | * @param starts 172 | */ 173 | endsWith(value: string, starts: string): boolean; 174 | 175 | /** 176 | * Returns the successor to passed string. 177 | * ('a') => 'b' 178 | * @param str 179 | */ 180 | succ(str: string): string; 181 | 182 | /** 183 | * Capitalize first letter of every word in the string. 184 | * ('my name is epeli') => 'My Name Is Epeli' 185 | * @param str 186 | */ 187 | titleize(str: string): string; 188 | 189 | /** 190 | * Converts underscored or dasherized string to a camelized one. 191 | * ('-moz-transform') => 'MozTransform' 192 | * @param str 193 | */ 194 | camelize(str: string): string; 195 | 196 | /** 197 | * Converts a camelized or dasherized string into an underscored one. 198 | * ('MozTransform') => 'moz_transform' 199 | * @param str 200 | */ 201 | underscored(str: string): string; 202 | 203 | /** 204 | * Converts a underscored or camelized string into an dasherized one. 205 | * ('MozTransform') => '-moz-transform' 206 | * @param str 207 | */ 208 | dasherize(str: string): string; 209 | 210 | /** 211 | * Converts string to camelized class name. 212 | * ('some_class_name') => 'SomeClassName' 213 | * @param str 214 | */ 215 | classify(str: string): string; 216 | 217 | /** 218 | * Converts an underscored, camelized, or dasherized string into a humanized one. 219 | * Also removes beginning and ending whitespace, and removes the postfix '_id'. 220 | * (' capitalize dash-CamelCase_underscore trim ') => 'Capitalize dash camel case underscore trim' 221 | * @param str 222 | */ 223 | humanize(str: string): string; 224 | 225 | /** 226 | * Trims defined characters from begining and ending of the string. 227 | * Defaults to whitespace characters. 228 | * (' foobar ') => 'foobar' 229 | * ('_-foobar-_', '_-') => 'foobar' 230 | * @param str 231 | * @param characters 232 | */ 233 | trim(str: string, characters?: string): string; 234 | 235 | /** 236 | * Trims defined characters from begining and ending of the string. 237 | * Defaults to whitespace characters. 238 | * (' foobar ') => 'foobar' 239 | * ('_-foobar-_', '_-') => 'foobar' 240 | * @param str 241 | * @param characters 242 | */ 243 | strip(str: string, characters?: string): string; 244 | 245 | /** 246 | * Left trim. Similar to trim, but only for left side. 247 | * @param str 248 | * @param characters 249 | */ 250 | ltrim(str: string, characters?: string): string; 251 | 252 | /** 253 | * Left trim. Similar to trim, but only for left side. 254 | * @param str 255 | * @param characters 256 | */ 257 | lstrip(str: string, characters?: string): string; 258 | 259 | /** 260 | * Right trim. Similar to trim, but only for right side. 261 | * @param str 262 | * @param characters 263 | */ 264 | rtrim(str: string, characters?: string): string; 265 | 266 | /** 267 | * Right trim. Similar to trim, but only for right side. 268 | * @param str 269 | * @param characters 270 | */ 271 | rstrip(str: string, characters?: string): string; 272 | 273 | /** 274 | * Truncate string to specified length. 275 | * ('Hello world').truncate(5) => 'Hello...' 276 | * ('Hello').truncate(10) => 'Hello' 277 | * @param str 278 | * @param length 279 | * @param truncateStr 280 | */ 281 | truncate(str: string, length: number, truncateStr?: string): string; 282 | 283 | /** 284 | * Elegant version of truncate. 285 | * Makes sure the pruned string does not exceed the original length. 286 | * Avoid half-chopped words when truncating. 287 | * ('Hello, cruel world', 15) => 'Hello, cruel...' 288 | * @param str 289 | * @param length 290 | * @param pruneStr 291 | */ 292 | prune(str: string, length: number, pruneStr?: string): string; 293 | 294 | /** 295 | * Split string by delimiter (String or RegExp). 296 | * /\s+/ by default. 297 | * (' I love you ') => ['I','love','you'] 298 | * ('I_love_you', '_') => ['I','love','you'] 299 | * @param str 300 | * @param delimiter 301 | */ 302 | words(str: string): string[]; 303 | 304 | /** 305 | * Split string by delimiter (String or RegExp). 306 | * /\s+/ by default. 307 | * (' I love you ') => ['I','love','you'] 308 | * ('I_love_you', '_') => ['I','love','you'] 309 | * @param str 310 | * @param delimiter 311 | */ 312 | words(str: string, delimiter: string): string[]; 313 | 314 | /** 315 | * Split string by delimiter (String or RegExp). 316 | * /\s+/ by default. 317 | * (' I love you ') => ['I','love','you'] 318 | * ('I_love_you', '_') => ['I','love','you'] 319 | * @param str 320 | * @param delimiter 321 | */ 322 | words(str: string, delimiter: RegExp): string[]; 323 | 324 | /** 325 | * Pads a string with characters until the total string length is equal to the passed length parameter. 326 | * By default, pads on the left with the space char (' '). 327 | * padStr is truncated to a single character if necessary. 328 | * ('1', 8) => ' 1' 329 | * ('1', 8, '0') => '00000001' 330 | * ('1', 8, '0', 'right') => '10000000' 331 | * ('1', 8, '0', 'both') => '00001000' 332 | * ('1', 8, 'bleepblorp', 'both') => 'bbbb1bbb' 333 | * @param str 334 | * @param length 335 | * @param padStr 336 | * @param type 337 | */ 338 | pad(str: string, length: number, padStr?:string, type?: string): string; 339 | 340 | /** 341 | * Left-pad a string. 342 | * Alias for pad(str, length, padStr, 'left') 343 | * ('1', 8, '0') => '00000001' 344 | * @param str 345 | * @param length 346 | * @param padStr 347 | */ 348 | lpad(str: string, length: number, padStr?: string): string; 349 | 350 | /** 351 | * Left-pad a string. 352 | * Alias for pad(str, length, padStr, 'left') 353 | * ('1', 8, '0') => '00000001' 354 | * @param str 355 | * @param length 356 | * @param padStr 357 | */ 358 | rjust(str: string, length: number, padStr?: string): string; 359 | 360 | /** 361 | * Right-pad a string. 362 | * Alias for pad(str, length, padStr, 'right') 363 | * ('1', 8, '0') => '10000000' 364 | * @param str 365 | * @param length 366 | * @param padStr 367 | */ 368 | rpad(str: string, length: number, padStr?: string): string; 369 | 370 | /** 371 | * Right-pad a string. 372 | * Alias for pad(str, length, padStr, 'right') 373 | * ('1', 8, '0') => '10000000' 374 | * @param str 375 | * @param length 376 | * @param padStr 377 | */ 378 | ljust(str: string, length: number, padStr?: string): string; 379 | 380 | /** 381 | * Left/right-pad a string. 382 | * Alias for pad(str, length, padStr, 'both') 383 | * ('1', 8, '0') => '00001000' 384 | * @param str 385 | * @param length 386 | * @param padStr 387 | */ 388 | lrpad(str: string, length: number, padStr?: string): string; 389 | 390 | /** 391 | * Left/right-pad a string. 392 | * Alias for pad(str, length, padStr, 'both') 393 | * ('1', 8, '0') => '00001000' 394 | * @param str 395 | * @param length 396 | * @param padStr 397 | */ 398 | center(str: string, length: number, padStr?: string): string; 399 | 400 | /** 401 | * C like string formatting. 402 | * _.sprintf('%.1f', 1.17) => '1.2' 403 | * @param format 404 | * @param args 405 | */ 406 | sprintf(format: string, ...args: any[]): string; 407 | 408 | /** 409 | * Parse string to number. 410 | * Returns NaN if string can't be parsed to number. 411 | * ('2.556').toNumber() => 3 412 | * ('2.556').toNumber(1) => 2.6 413 | * @param str 414 | * @param decimals 415 | */ 416 | toNumber(str: string, decimals?: number): number; 417 | 418 | /** 419 | * Formats the numbers. 420 | * (1000, 2) => '1,000.00' 421 | * (123456789.123, 5, '.', ',') => '123,456,789.12300' 422 | * @param number 423 | * @param dec 424 | * @param dsep 425 | * @param tsep 426 | */ 427 | numberFormat(number: number, dec?: number, dsep?: string, tsep?: string): string; 428 | 429 | /** 430 | * Searches a string from left to right for a pattern. 431 | * Returns a substring consisting of the characters in the string that are to the right of the pattern. 432 | * If no match found, returns entire string. 433 | * ('This_is_a_test_string').strRight('_') => 'is_a_test_string' 434 | * @param str 435 | * @param sep 436 | */ 437 | strRight(str: string, sep: string): string; 438 | 439 | /** 440 | * Searches a string from right to left for a pattern. 441 | * Returns a substring consisting of the characters in the string that are to the right of the pattern. 442 | * If no match found, returns entire string. 443 | * ('This_is_a_test_string').strRightBack('_') => 'string' 444 | * @param str 445 | * @param sep 446 | */ 447 | strRightBack(str: string, sep: string): string; 448 | 449 | /** 450 | * Searches a string from left to right for a pattern. 451 | * Returns a substring consisting of the characters in the string that are to the left of the pattern. 452 | * If no match found, returns entire string. 453 | * ('This_is_a_test_string').strLeft('_') => 'This' 454 | * @param str 455 | * @param sep 456 | */ 457 | strLeft(str: string, sep: string): string; 458 | 459 | /** 460 | * Searches a string from right to left for a pattern. 461 | * Returns a substring consisting of the characters in the string that are to the left of the pattern. 462 | * If no match found, returns entire string. 463 | * ('This_is_a_test_string').strLeftBack('_') => 'This_is_a_test' 464 | * @param str 465 | * @param sep 466 | */ 467 | strLeftBack(str: string, sep: string): string; 468 | 469 | /** 470 | * Join an array into a human readable sentence. 471 | * (['jQuery', 'Mootools', 'Prototype']) => 'jQuery, Mootools and Prototype' 472 | * (['jQuery', 'Mootools', 'Prototype'], ', ', ' unt ') => 'jQuery, Mootools unt Prototype' 473 | * @param array 474 | * @param separator 475 | * @param lastSeparator 476 | * @param serial 477 | */ 478 | toSentence(array: any[], separator?: string, lastSeparator?: string, serial?: boolean): string; 479 | 480 | /** 481 | * The same as toSentence, but uses ', ' as default for lastSeparator. 482 | * @param array 483 | * @param separator 484 | * @param lastSeparator 485 | */ 486 | toSentenceSerial(array: any[], separator?: string, lastSeparator?: string): string; 487 | 488 | /** 489 | * Transform text into a URL slug. Replaces whitespaces, accentuated, and special characters with a dash. 490 | * ('Un éléphant à l'orée du bois') => 'un-elephant-a-loree-du-bois' 491 | * @param str 492 | */ 493 | slugify(str: string): string; 494 | 495 | /** 496 | * Surround a string with another string. 497 | * ('foo', 'ab') => 'abfooab' 498 | * @param str 499 | * @param wrapper 500 | */ 501 | surround(str: string, wrapper: string): string; 502 | 503 | /** 504 | * Quotes a string. 505 | * quoteChar defaults to " 506 | * ('foo') => '"foo"' 507 | * @param str 508 | */ 509 | quote(str: string, quoteChar?: string): string; 510 | 511 | /** 512 | * Quotes a string. 513 | * quoteChar defaults to " 514 | * ('foo') => '"foo"' 515 | * @param str 516 | */ 517 | q(str: string, quoteChar?: string): string; 518 | 519 | /** 520 | * Unquotes a string. 521 | * quoteChar defaults to " 522 | * ('"foo"') => 'foo' 523 | * ("'foo'", "'") => 'foo' 524 | * @param str 525 | */ 526 | unquote(str: string, quoteChar?: string): string; 527 | 528 | /** 529 | * Repeat a string with an optional separator. 530 | * ('foo', 3) => 'foofoofoo' 531 | * ('foo', 3, 'bar') => 'foobarfoobarfoo' 532 | * @param value 533 | * @param count 534 | * @param separator 535 | */ 536 | repeat(value: string, count: number, separator?:string): string; 537 | 538 | /** 539 | * Naturally sort strings like humans would do. 540 | * Caution: this function is charset dependent. 541 | * @param str1 542 | * @param str2 543 | */ 544 | naturalCmp(str1: string, str2: string): number; 545 | 546 | /** 547 | * Calculates Levenshtein distance between two strings. 548 | * ('kitten', 'kittah') => 2 549 | * @param str1 550 | * @param str2 551 | */ 552 | levenshtein(str1: string, str2: string): number; 553 | 554 | /** 555 | * Turn strings that can be commonly considered as booleans to real booleans. 556 | * Such as "true", "false", "1" and "0". This function is case insensitive. 557 | * ('true') => true 558 | * ('FALSE') => false 559 | * ('random') => undefined 560 | * ('truthy', ['truthy'], ['falsy']) => true 561 | * ('true only at start', [/^true/]) => true 562 | * @param str 563 | * @param trueValues 564 | * @param falseValues 565 | */ 566 | toBoolean(str: string, trueValues?: any[], falseValues?: any[]): boolean; 567 | 568 | } 569 | declare module 'underscore.string' { 570 | var underscoreString: UnderscoreStringStatic; 571 | export = underscoreString; 572 | } 573 | // TODO interface UnderscoreString extends Underscore 574 | -------------------------------------------------------------------------------- /typings/underscore/underscore.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for Underscore 1.7.0 2 | // Project: http://underscorejs.org/ 3 | // Definitions by: Boris Yankov , Josh Baldwin 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 Collection { } 45 | 46 | // Common interface between Arrays and jQuery objects 47 | interface List extends Collection { 48 | [index: number]: T; 49 | length: number; 50 | } 51 | 52 | interface Dictionary extends Collection { 53 | [index: string]: T; 54 | } 55 | 56 | interface ListIterator { 57 | (value: T, index: number, list: List): TResult; 58 | } 59 | 60 | interface ObjectIterator { 61 | (element: T, key: string, list: Dictionary): TResult; 62 | } 63 | 64 | interface MemoIterator { 65 | (prev: TResult, curr: T, index: number, list: List): TResult; 66 | } 67 | 68 | interface MemoObjectIterator { 69 | (prev: TResult, curr: T, key: string, list: Dictionary): TResult; 70 | } 71 | } 72 | 73 | interface UnderscoreStatic { 74 | /** 75 | * Underscore OOP Wrapper, all Underscore functions that take an object 76 | * as the first parameter can be invoked through this function. 77 | * @param key First argument to Underscore object functions. 78 | **/ 79 | (value: Array): Underscore; 80 | (value: T): Underscore; 81 | 82 | /* ************* 83 | * Collections * 84 | ************* */ 85 | 86 | /** 87 | * Iterates over a list of elements, yielding each in turn to an iterator function. The iterator is 88 | * bound to the context object, if one is passed. Each invocation of iterator is called with three 89 | * arguments: (element, index, list). If list is a JavaScript object, iterator's arguments will be 90 | * (value, key, object). Delegates to the native forEach function if it exists. 91 | * @param list Iterates over this list of elements. 92 | * @param iterator Iterator function for each element `list`. 93 | * @param context 'this' object in `iterator`, optional. 94 | **/ 95 | each( 96 | list: _.List, 97 | iterator: _.ListIterator, 98 | context?: any): _.List; 99 | 100 | /** 101 | * @see _.each 102 | * @param object Iterates over properties of this object. 103 | * @param iterator Iterator function for each property on `object`. 104 | * @param context 'this' object in `iterator`, optional. 105 | **/ 106 | each( 107 | object: _.Dictionary, 108 | iterator: _.ObjectIterator, 109 | context?: any): _.Dictionary; 110 | 111 | /** 112 | * @see _.each 113 | **/ 114 | forEach( 115 | list: _.List, 116 | iterator: _.ListIterator, 117 | context?: any): _.List; 118 | 119 | /** 120 | * @see _.each 121 | **/ 122 | forEach( 123 | object: _.Dictionary, 124 | iterator: _.ObjectIterator, 125 | context?: any): _.Dictionary; 126 | 127 | /** 128 | * Produces a new array of values by mapping each value in list through a transformation function 129 | * (iterator). If the native map method exists, it will be used instead. If list is a JavaScript 130 | * object, iterator's arguments will be (value, key, object). 131 | * @param list Maps the elements of this array. 132 | * @param iterator Map iterator function for each element in `list`. 133 | * @param context `this` object in `iterator`, optional. 134 | * @return The mapped array result. 135 | **/ 136 | map( 137 | list: _.List, 138 | iterator: _.ListIterator, 139 | context?: any): TResult[]; 140 | 141 | /** 142 | * @see _.map 143 | * @param object Maps the properties of this object. 144 | * @param iterator Map iterator function for each property on `object`. 145 | * @param context `this` object in `iterator`, optional. 146 | * @return The mapped object result. 147 | **/ 148 | map( 149 | object: _.Dictionary, 150 | iterator: _.ObjectIterator, 151 | context?: any): TResult[]; 152 | 153 | /** 154 | * @see _.map 155 | **/ 156 | collect( 157 | list: _.List, 158 | iterator: _.ListIterator, 159 | context?: any): TResult[]; 160 | 161 | /** 162 | * @see _.map 163 | **/ 164 | collect( 165 | object: _.Dictionary, 166 | iterator: _.ObjectIterator, 167 | context?: any): TResult[]; 168 | 169 | /** 170 | * Also known as inject and foldl, reduce boils down a list of values into a single value. 171 | * Memo is the initial state of the reduction, and each successive step of it should be 172 | * returned by iterator. The iterator is passed four arguments: the memo, then the value 173 | * and index (or key) of the iteration, and finally a reference to the entire list. 174 | * @param list Reduces the elements of this array. 175 | * @param iterator Reduce iterator function for each element in `list`. 176 | * @param memo Initial reduce state. 177 | * @param context `this` object in `iterator`, optional. 178 | * @return Reduced object result. 179 | **/ 180 | reduce( 181 | list: _.Collection, 182 | iterator: _.MemoIterator, 183 | memo?: TResult, 184 | context?: any): TResult; 185 | 186 | reduce( 187 | list: _.Dictionary, 188 | iterator: _.MemoObjectIterator, 189 | memo?: TResult, 190 | context?: any): TResult; 191 | 192 | /** 193 | * @see _.reduce 194 | **/ 195 | inject( 196 | list: _.Collection, 197 | iterator: _.MemoIterator, 198 | memo?: TResult, 199 | context?: any): TResult; 200 | 201 | /** 202 | * @see _.reduce 203 | **/ 204 | foldl( 205 | list: _.Collection, 206 | iterator: _.MemoIterator, 207 | memo?: TResult, 208 | context?: any): TResult; 209 | 210 | /** 211 | * The right-associative version of reduce. Delegates to the JavaScript 1.8 version of 212 | * reduceRight, if it exists. `foldr` is not as useful in JavaScript as it would be in a 213 | * language with lazy evaluation. 214 | * @param list Reduces the elements of this array. 215 | * @param iterator Reduce iterator function for each element in `list`. 216 | * @param memo Initial reduce state. 217 | * @param context `this` object in `iterator`, optional. 218 | * @return Reduced object result. 219 | **/ 220 | reduceRight( 221 | list: _.Collection, 222 | iterator: _.MemoIterator, 223 | memo?: TResult, 224 | context?: any): TResult; 225 | 226 | /** 227 | * @see _.reduceRight 228 | **/ 229 | foldr( 230 | list: _.Collection, 231 | iterator: _.MemoIterator, 232 | memo?: TResult, 233 | context?: any): TResult; 234 | 235 | /** 236 | * Looks through each value in the list, returning the first one that passes a truth 237 | * test (iterator). The function returns as soon as it finds an acceptable element, 238 | * and doesn't traverse the entire list. 239 | * @param list Searches for a value in this list. 240 | * @param iterator Search iterator function for each element in `list`. 241 | * @param context `this` object in `iterator`, optional. 242 | * @return The first acceptable found element in `list`, if nothing is found undefined/null is returned. 243 | **/ 244 | find( 245 | list: _.List, 246 | iterator: _.ListIterator, 247 | context?: any): T; 248 | 249 | /** 250 | * @see _.find 251 | **/ 252 | find( 253 | object: _.Dictionary, 254 | iterator: _.ObjectIterator, 255 | context?: any): T; 256 | 257 | /** 258 | * @see _.find 259 | **/ 260 | detect( 261 | list: _.List, 262 | iterator: _.ListIterator, 263 | context?: any): T; 264 | 265 | /** 266 | * @see _.find 267 | **/ 268 | detect( 269 | object: _.Dictionary, 270 | iterator: _.ObjectIterator, 271 | context?: any): T; 272 | 273 | /** 274 | * Looks through each value in the list, returning the index of the first one that passes a truth 275 | * test (iterator). The function returns as soon as it finds an acceptable element, 276 | * and doesn't traverse the entire list. 277 | * @param list Searches for a value in this list. 278 | * @param iterator Search iterator function for each element in `list`. 279 | * @param context `this` object in `iterator`, optional. 280 | * @return The index of the first acceptable found element in `list`, if nothing is found -1 is returned. 281 | **/ 282 | findIndex( 283 | list: _.List, 284 | iterator: _.ListIterator, 285 | context?: any): number; 286 | 287 | 288 | /** 289 | * Looks through each value in the list, returning an array of all the values that pass a truth 290 | * test (iterator). Delegates to the native filter method, if it exists. 291 | * @param list Filter elements out of this list. 292 | * @param iterator Filter iterator function for each element in `list`. 293 | * @param context `this` object in `iterator`, optional. 294 | * @return The filtered list of elements. 295 | **/ 296 | filter( 297 | list: _.List, 298 | iterator: _.ListIterator, 299 | context?: any): T[]; 300 | 301 | /** 302 | * @see _.filter 303 | **/ 304 | filter( 305 | object: _.Dictionary, 306 | iterator: _.ObjectIterator, 307 | context?: any): T[]; 308 | 309 | /** 310 | * @see _.filter 311 | **/ 312 | select( 313 | list: _.List, 314 | iterator: _.ListIterator, 315 | context?: any): T[]; 316 | 317 | /** 318 | * @see _.filter 319 | **/ 320 | select( 321 | object: _.Dictionary, 322 | iterator: _.ObjectIterator, 323 | context?: any): T[]; 324 | 325 | /** 326 | * Looks through each value in the list, returning an array of all the values that contain all 327 | * of the key-value pairs listed in properties. 328 | * @param list List to match elements again `properties`. 329 | * @param properties The properties to check for on each element within `list`. 330 | * @return The elements within `list` that contain the required `properties`. 331 | **/ 332 | where( 333 | list: _.List, 334 | properties: U): T[]; 335 | 336 | /** 337 | * Looks through the list and returns the first value that matches all of the key-value pairs listed in properties. 338 | * @param list Search through this list's elements for the first object with all `properties`. 339 | * @param properties Properties to look for on the elements within `list`. 340 | * @return The first element in `list` that has all `properties`. 341 | **/ 342 | findWhere( 343 | list: _.List, 344 | properties: U): T; 345 | 346 | /** 347 | * Returns the values in list without the elements that the truth test (iterator) passes. 348 | * The opposite of filter. 349 | * Return all the elements for which a truth test fails. 350 | * @param list Reject elements within this list. 351 | * @param iterator Reject iterator function for each element in `list`. 352 | * @param context `this` object in `iterator`, optional. 353 | * @return The rejected list of elements. 354 | **/ 355 | reject( 356 | list: _.List, 357 | iterator: _.ListIterator, 358 | context?: any): T[]; 359 | 360 | /** 361 | * @see _.reject 362 | **/ 363 | reject( 364 | object: _.Dictionary, 365 | iterator: _.ObjectIterator, 366 | context?: any): T[]; 367 | 368 | /** 369 | * Returns true if all of the values in the list pass the iterator truth test. Delegates to the 370 | * native method every, if present. 371 | * @param list Truth test against all elements within this list. 372 | * @param iterator Trust test iterator function for each element in `list`. 373 | * @param context `this` object in `iterator`, optional. 374 | * @return True if all elements passed the truth test, otherwise false. 375 | **/ 376 | every( 377 | list: _.List, 378 | iterator?: _.ListIterator, 379 | context?: any): boolean; 380 | 381 | /** 382 | * @see _.every 383 | **/ 384 | every( 385 | list: _.Dictionary, 386 | iterator?: _.ObjectIterator, 387 | context?: any): boolean; 388 | 389 | /** 390 | * @see _.every 391 | **/ 392 | all( 393 | list: _.List, 394 | iterator?: _.ListIterator, 395 | context?: any): boolean; 396 | 397 | /** 398 | * @see _.every 399 | **/ 400 | all( 401 | list: _.Dictionary, 402 | iterator?: _.ObjectIterator, 403 | context?: any): boolean; 404 | 405 | /** 406 | * Returns true if any of the values in the list pass the iterator truth test. Short-circuits and 407 | * stops traversing the list if a true element is found. Delegates to the native method some, if present. 408 | * @param list Truth test against all elements within this list. 409 | * @param iterator Trust test iterator function for each element in `list`. 410 | * @param context `this` object in `iterator`, optional. 411 | * @return True if any elements passed the truth test, otherwise false. 412 | **/ 413 | some( 414 | list: _.List, 415 | iterator?: _.ListIterator, 416 | context?: any): boolean; 417 | 418 | /** 419 | * @see _.some 420 | **/ 421 | some( 422 | object: _.Dictionary, 423 | iterator?: _.ObjectIterator, 424 | context?: any): boolean; 425 | 426 | /** 427 | * @see _.some 428 | **/ 429 | any( 430 | list: _.List, 431 | iterator?: _.ListIterator, 432 | context?: any): boolean; 433 | 434 | /** 435 | * @see _.some 436 | **/ 437 | any( 438 | object: _.Dictionary, 439 | iterator?: _.ObjectIterator, 440 | context?: any): boolean; 441 | 442 | /** 443 | * Returns true if the value is present in the list. Uses indexOf internally, 444 | * if list is an Array. 445 | * @param list Checks each element to see if `value` is present. 446 | * @param value The value to check for within `list`. 447 | * @return True if `value` is present in `list`, otherwise false. 448 | **/ 449 | contains( 450 | list: _.List, 451 | value: T): boolean; 452 | 453 | /** 454 | * @see _.contains 455 | **/ 456 | contains( 457 | object: _.Dictionary, 458 | value: T): boolean; 459 | 460 | /** 461 | * @see _.contains 462 | **/ 463 | include( 464 | list: _.Collection, 465 | value: T): boolean; 466 | 467 | /** 468 | * @see _.contains 469 | **/ 470 | include( 471 | object: _.Dictionary, 472 | value: T): boolean; 473 | 474 | /** 475 | * Calls the method named by methodName on each value in the list. Any extra arguments passed to 476 | * invoke will be forwarded on to the method invocation. 477 | * @param list The element's in this list will each have the method `methodName` invoked. 478 | * @param methodName The method's name to call on each element within `list`. 479 | * @param arguments Additional arguments to pass to the method `methodName`. 480 | **/ 481 | invoke( 482 | list: _.List, 483 | methodName: string, 484 | ...arguments: any[]): any; 485 | 486 | /** 487 | * A convenient version of what is perhaps the most common use-case for map: extracting a list of 488 | * property values. 489 | * @param list The list to pluck elements out of that have the property `propertyName`. 490 | * @param propertyName The property to look for on each element within `list`. 491 | * @return The list of elements within `list` that have the property `propertyName`. 492 | **/ 493 | pluck( 494 | list: _.List, 495 | propertyName: string): any[]; 496 | 497 | /** 498 | * Returns the maximum value in list. 499 | * @param list Finds the maximum value in this list. 500 | * @return Maximum value in `list`. 501 | **/ 502 | max(list: _.List): number; 503 | 504 | /** 505 | * Returns the maximum value in list. If iterator is passed, it will be used on each value to generate 506 | * the criterion by which the value is ranked. 507 | * @param list Finds the maximum value in this list. 508 | * @param iterator Compares each element in `list` to find the maximum value. 509 | * @param context `this` object in `iterator`, optional. 510 | * @return The maximum element within `list`. 511 | **/ 512 | max( 513 | list: _.List, 514 | iterator?: _.ListIterator, 515 | context?: any): T; 516 | 517 | /** 518 | * Returns the minimum value in list. 519 | * @param list Finds the minimum value in this list. 520 | * @return Minimum value in `list`. 521 | **/ 522 | min(list: _.List): number; 523 | 524 | /** 525 | * Returns the minimum value in list. If iterator is passed, it will be used on each value to generate 526 | * the criterion by which the value is ranked. 527 | * @param list Finds the minimum value in this list. 528 | * @param iterator Compares each element in `list` to find the minimum value. 529 | * @param context `this` object in `iterator`, optional. 530 | * @return The minimum element within `list`. 531 | **/ 532 | min( 533 | list: _.List, 534 | iterator?: _.ListIterator, 535 | context?: any): T; 536 | 537 | /** 538 | * Returns a sorted copy of list, ranked in ascending order by the results of running each value 539 | * through iterator. Iterator may also be the string name of the property to sort by (eg. length). 540 | * @param list Sorts this list. 541 | * @param iterator Sort iterator for each element within `list`. 542 | * @param context `this` object in `iterator`, optional. 543 | * @return A sorted copy of `list`. 544 | **/ 545 | sortBy( 546 | list: _.List, 547 | iterator?: _.ListIterator, 548 | context?: any): T[]; 549 | 550 | /** 551 | * @see _.sortBy 552 | * @param iterator Sort iterator for each element within `list`. 553 | **/ 554 | sortBy( 555 | list: _.List, 556 | iterator: string, 557 | context?: any): T[]; 558 | 559 | /** 560 | * Splits a collection into sets, grouped by the result of running each value through iterator. 561 | * If iterator is a string instead of a function, groups by the property named by iterator on 562 | * each of the values. 563 | * @param list Groups this list. 564 | * @param iterator Group iterator for each element within `list`, return the key to group the element by. 565 | * @param context `this` object in `iterator`, optional. 566 | * @return An object with the group names as properties where each property contains the grouped elements from `list`. 567 | **/ 568 | groupBy( 569 | list: _.List, 570 | iterator?: _.ListIterator, 571 | context?: any): _.Dictionary; 572 | 573 | /** 574 | * @see _.groupBy 575 | * @param iterator Property on each object to group them by. 576 | **/ 577 | groupBy( 578 | list: _.List, 579 | iterator: string, 580 | context?: any): _.Dictionary; 581 | 582 | /** 583 | * Given a `list`, and an `iterator` function that returns a key for each element in the list (or a property name), 584 | * returns an object with an index of each item. Just like _.groupBy, but for when you know your keys are unique. 585 | **/ 586 | indexBy( 587 | list: _.List, 588 | iterator: _.ListIterator, 589 | context?: any): _.Dictionary; 590 | 591 | /** 592 | * @see _.indexBy 593 | * @param iterator Property on each object to index them by. 594 | **/ 595 | indexBy( 596 | list: _.List, 597 | iterator: string, 598 | context?: any): _.Dictionary; 599 | 600 | /** 601 | * Sorts a list into groups and returns a count for the number of objects in each group. Similar 602 | * to groupBy, but instead of returning a list of values, returns a count for the number of values 603 | * in that group. 604 | * @param list Group elements in this list and then count the number of elements in each group. 605 | * @param iterator Group iterator for each element within `list`, return the key to group the element by. 606 | * @param context `this` object in `iterator`, optional. 607 | * @return An object with the group names as properties where each property contains the number of elements in that group. 608 | **/ 609 | countBy( 610 | list: _.List, 611 | iterator?: _.ListIterator, 612 | context?: any): _.Dictionary; 613 | 614 | /** 615 | * @see _.countBy 616 | * @param iterator Function name 617 | **/ 618 | countBy( 619 | list: _.List, 620 | iterator: string, 621 | context?: any): _.Dictionary; 622 | 623 | /** 624 | * Returns a shuffled copy of the list, using a version of the Fisher-Yates shuffle. 625 | * @param list List to shuffle. 626 | * @return Shuffled copy of `list`. 627 | **/ 628 | shuffle(list: _.Collection): T[]; 629 | 630 | /** 631 | * 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. 632 | * @param list List to sample. 633 | * @return Random sample of `n` elements in `list`. 634 | **/ 635 | sample(list: _.Collection, n: number): T[]; 636 | 637 | /** 638 | * @see _.sample 639 | **/ 640 | sample(list: _.Collection): T; 641 | 642 | /** 643 | * Converts the list (anything that can be iterated over), into a real Array. Useful for transmuting 644 | * the arguments object. 645 | * @param list object to transform into an array. 646 | * @return `list` as an array. 647 | **/ 648 | toArray(list: _.Collection): T[]; 649 | 650 | /** 651 | * Return the number of values in the list. 652 | * @param list Count the number of values/elements in this list. 653 | * @return Number of values in `list`. 654 | **/ 655 | size(list: _.Collection): number; 656 | 657 | /** 658 | * Split array into two arrays: 659 | * one whose elements all satisfy predicate and one whose elements all do not satisfy predicate. 660 | * @param array Array to split in two. 661 | * @param iterator Filter iterator function for each element in `array`. 662 | * @param context `this` object in `iterator`, optional. 663 | * @return Array where Array[0] are the elements in `array` that satisfies the predicate, and Array[1] the elements that did not. 664 | **/ 665 | partition( 666 | array: Array, 667 | iterator: _.ListIterator, 668 | context?: any): T[][]; 669 | 670 | /********* 671 | * Arrays * 672 | **********/ 673 | 674 | /** 675 | * Returns the first element of an array. Passing n will return the first n elements of the array. 676 | * @param array Retrieves the first element of this array. 677 | * @return Returns the first element of `array`. 678 | **/ 679 | first(array: _.List): T; 680 | 681 | /** 682 | * @see _.first 683 | * @param n Return more than one element from `array`. 684 | **/ 685 | first( 686 | array: _.List, 687 | n: number): T[]; 688 | 689 | /** 690 | * @see _.first 691 | **/ 692 | head(array: _.List): T; 693 | 694 | /** 695 | * @see _.first 696 | **/ 697 | head( 698 | array: _.List, 699 | n: number): T[]; 700 | 701 | /** 702 | * @see _.first 703 | **/ 704 | take(array: _.List): T; 705 | 706 | /** 707 | * @see _.first 708 | **/ 709 | take( 710 | array: _.List, 711 | n: number): T[]; 712 | 713 | /** 714 | * Returns everything but the last entry of the array. Especially useful on the arguments object. 715 | * Pass n to exclude the last n elements from the result. 716 | * @param array Retrieve all elements except the last `n`. 717 | * @param n Leaves this many elements behind, optional. 718 | * @return Returns everything but the last `n` elements of `array`. 719 | **/ 720 | initial( 721 | array: _.List, 722 | n?: number): T[]; 723 | 724 | /** 725 | * Returns the last element of an array. Passing n will return the last n elements of the array. 726 | * @param array Retrieves the last element of this array. 727 | * @return Returns the last element of `array`. 728 | **/ 729 | last(array: _.List): T; 730 | 731 | /** 732 | * @see _.last 733 | * @param n Return more than one element from `array`. 734 | **/ 735 | last( 736 | array: _.List, 737 | n: number): T[]; 738 | 739 | /** 740 | * Returns the rest of the elements in an array. Pass an index to return the values of the array 741 | * from that index onward. 742 | * @param array The array to retrieve all but the first `index` elements. 743 | * @param n The index to start retrieving elements forward from, optional, default = 1. 744 | * @return Returns the elements of `array` from `index` to the end of `array`. 745 | **/ 746 | rest( 747 | array: _.List, 748 | n?: number): T[]; 749 | 750 | /** 751 | * @see _.rest 752 | **/ 753 | tail( 754 | array: _.List, 755 | n?: number): T[]; 756 | 757 | /** 758 | * @see _.rest 759 | **/ 760 | drop( 761 | array: _.List, 762 | n?: number): T[]; 763 | 764 | /** 765 | * Returns a copy of the array with all falsy values removed. In JavaScript, false, null, 0, "", 766 | * undefined and NaN are all falsy. 767 | * @param array Array to compact. 768 | * @return Copy of `array` without false values. 769 | **/ 770 | compact(array: _.List): T[]; 771 | 772 | /** 773 | * Flattens a nested array (the nesting can be to any depth). If you pass shallow, the array will 774 | * only be flattened a single level. 775 | * @param array The array to flatten. 776 | * @param shallow If true then only flatten one level, optional, default = false. 777 | * @return `array` flattened. 778 | **/ 779 | flatten( 780 | array: _.List, 781 | shallow?: boolean): any[]; 782 | 783 | /** 784 | * Returns a copy of the array with all instances of the values removed. 785 | * @param array The array to remove `values` from. 786 | * @param values The values to remove from `array`. 787 | * @return Copy of `array` without `values`. 788 | **/ 789 | without( 790 | array: _.List, 791 | ...values: T[]): T[]; 792 | 793 | /** 794 | * Computes the union of the passed-in arrays: the list of unique items, in order, that are 795 | * present in one or more of the arrays. 796 | * @param arrays Array of arrays to compute the union of. 797 | * @return The union of elements within `arrays`. 798 | **/ 799 | union(...arrays: _.List[]): T[]; 800 | 801 | /** 802 | * Computes the list of values that are the intersection of all the arrays. Each value in the result 803 | * is present in each of the arrays. 804 | * @param arrays Array of arrays to compute the intersection of. 805 | * @return The intersection of elements within `arrays`. 806 | **/ 807 | intersection(...arrays: _.List[]): T[]; 808 | 809 | /** 810 | * Similar to without, but returns the values from array that are not present in the other arrays. 811 | * @param array Keeps values that are within `others`. 812 | * @param others The values to keep within `array`. 813 | * @return Copy of `array` with only `others` values. 814 | **/ 815 | difference( 816 | array: _.List, 817 | ...others: _.List[]): T[]; 818 | 819 | /** 820 | * Produces a duplicate-free version of the array, using === to test object equality. If you know in 821 | * advance that the array is sorted, passing true for isSorted will run a much faster algorithm. If 822 | * you want to compute unique items based on a transformation, pass an iterator function. 823 | * @param array Array to remove duplicates from. 824 | * @param isSorted True if `array` is already sorted, optional, default = false. 825 | * @param iterator Transform the elements of `array` before comparisons for uniqueness. 826 | * @param context 'this' object in `iterator`, optional. 827 | * @return Copy of `array` where all elements are unique. 828 | **/ 829 | uniq( 830 | array: _.List, 831 | isSorted?: boolean, 832 | iterator?: _.ListIterator, 833 | context?: any): T[]; 834 | 835 | /** 836 | * @see _.uniq 837 | **/ 838 | uniq( 839 | array: _.List, 840 | iterator?: _.ListIterator, 841 | context?: any): T[]; 842 | 843 | /** 844 | * @see _.uniq 845 | **/ 846 | unique( 847 | array: _.List, 848 | iterator?: _.ListIterator, 849 | context?: any): T[]; 850 | 851 | /** 852 | * @see _.uniq 853 | **/ 854 | unique( 855 | array: _.List, 856 | isSorted?: boolean, 857 | iterator?: _.ListIterator, 858 | context?: any): T[]; 859 | 860 | 861 | /** 862 | * Merges together the values of each of the arrays with the values at the corresponding position. 863 | * Useful when you have separate data sources that are coordinated through matching array indexes. 864 | * If you're working with a matrix of nested arrays, zip.apply can transpose the matrix in a similar fashion. 865 | * @param arrays The arrays to merge/zip. 866 | * @return Zipped version of `arrays`. 867 | **/ 868 | zip(...arrays: any[][]): any[][]; 869 | 870 | /** 871 | * @see _.zip 872 | **/ 873 | zip(...arrays: any[]): any[]; 874 | 875 | /** 876 | * Converts arrays into objects. Pass either a single list of [key, value] pairs, or a 877 | * list of keys, and a list of values. 878 | * @param keys Key array. 879 | * @param values Value array. 880 | * @return An object containing the `keys` as properties and `values` as the property values. 881 | **/ 882 | object( 883 | keys: _.List, 884 | values: _.List): TResult; 885 | 886 | /** 887 | * Converts arrays into objects. Pass either a single list of [key, value] pairs, or a 888 | * list of keys, and a list of values. 889 | * @param keyValuePairs Array of [key, value] pairs. 890 | * @return An object containing the `keys` as properties and `values` as the property values. 891 | **/ 892 | object(...keyValuePairs: any[][]): TResult; 893 | 894 | /** 895 | * @see _.object 896 | **/ 897 | object( 898 | list: _.List, 899 | values?: any): TResult; 900 | 901 | /** 902 | * Returns the index at which value can be found in the array, or -1 if value is not present in the array. 903 | * Uses the native indexOf function unless it's missing. If you're working with a large array, and you know 904 | * that the array is already sorted, pass true for isSorted to use a faster binary search ... or, pass a number 905 | * as the third argument in order to look for the first matching value in the array after the given index. 906 | * @param array The array to search for the index of `value`. 907 | * @param value The value to search for within `array`. 908 | * @param isSorted True if the array is already sorted, optional, default = false. 909 | * @return The index of `value` within `array`. 910 | **/ 911 | indexOf( 912 | array: _.List, 913 | value: T, 914 | isSorted?: boolean): number; 915 | 916 | /** 917 | * @see _indexof 918 | **/ 919 | indexOf( 920 | array: _.List, 921 | value: T, 922 | startFrom: number): number; 923 | 924 | /** 925 | * Returns the index of the last occurrence of value in the array, or -1 if value is not present. Uses the 926 | * native lastIndexOf function if possible. Pass fromIndex to start your search at a given index. 927 | * @param array The array to search for the last index of `value`. 928 | * @param value The value to search for within `array`. 929 | * @param from The starting index for the search, optional. 930 | * @return The index of the last occurrence of `value` within `array`. 931 | **/ 932 | lastIndexOf( 933 | array: _.List, 934 | value: T, 935 | from?: number): number; 936 | 937 | /** 938 | * Uses a binary search to determine the index at which the value should be inserted into the list in order 939 | * to maintain the list's sorted order. If an iterator is passed, it will be used to compute the sort ranking 940 | * of each value, including the value you pass. 941 | * @param list The sorted list. 942 | * @param value The value to determine its index within `list`. 943 | * @param iterator Iterator to compute the sort ranking of each value, optional. 944 | * @return The index where `value` should be inserted into `list`. 945 | **/ 946 | sortedIndex( 947 | list: _.List, 948 | value: T, 949 | iterator?: (x: T) => TSort, context?: any): number; 950 | 951 | /** 952 | * A function to create flexibly-numbered lists of integers, handy for each and map loops. start, if omitted, 953 | * defaults to 0; step defaults to 1. Returns a list of integers from start to stop, incremented (or decremented) 954 | * by step, exclusive. 955 | * @param start Start here. 956 | * @param stop Stop here. 957 | * @param step The number to count up by each iteration, optional, default = 1. 958 | * @return Array of numbers from `start` to `stop` with increments of `step`. 959 | **/ 960 | 961 | range( 962 | start: number, 963 | stop: number, 964 | step?: number): number[]; 965 | 966 | /** 967 | * @see _.range 968 | * @param stop Stop here. 969 | * @return Array of numbers from 0 to `stop` with increments of 1. 970 | * @note If start is not specified the implementation will never pull the step (step = arguments[2] || 0) 971 | **/ 972 | range(stop: number): number[]; 973 | 974 | /************* 975 | * Functions * 976 | *************/ 977 | 978 | /** 979 | * Bind a function to an object, meaning that whenever the function is called, the value of this will 980 | * be the object. Optionally, bind arguments to the function to pre-fill them, also known as partial application. 981 | * @param func The function to bind `this` to `object`. 982 | * @param context The `this` pointer whenever `fn` is called. 983 | * @param arguments Additional arguments to pass to `fn` when called. 984 | * @return `fn` with `this` bound to `object`. 985 | **/ 986 | bind( 987 | func: Function, 988 | context: any, 989 | ...arguments: any[]): () => any; 990 | 991 | /** 992 | * Binds a number of methods on the object, specified by methodNames, to be run in the context of that object 993 | * whenever they are invoked. Very handy for binding functions that are going to be used as event handlers, 994 | * which would otherwise be invoked with a fairly useless this. If no methodNames are provided, all of the 995 | * object's function properties will be bound to it. 996 | * @param object The object to bind the methods `methodName` to. 997 | * @param methodNames The methods to bind to `object`, optional and if not provided all of `object`'s 998 | * methods are bound. 999 | **/ 1000 | bindAll( 1001 | object: any, 1002 | ...methodNames: string[]): any; 1003 | 1004 | /** 1005 | * Partially apply a function by filling in any number of its arguments, without changing its dynamic this value. 1006 | * A close cousin of bind. You may pass _ in your list of arguments to specify an argument that should not be 1007 | * pre-filled, but left open to supply at call-time. 1008 | * @param fn Function to partially fill in arguments. 1009 | * @param arguments The partial arguments. 1010 | * @return `fn` with partially filled in arguments. 1011 | **/ 1012 | partial( 1013 | fn: Function, 1014 | ...arguments: any[]): Function; 1015 | 1016 | /** 1017 | * Memoizes a given function by caching the computed result. Useful for speeding up slow-running computations. 1018 | * If passed an optional hashFunction, it will be used to compute the hash key for storing the result, based 1019 | * on the arguments to the original function. The default hashFunction just uses the first argument to the 1020 | * memoized function as the key. 1021 | * @param fn Computationally expensive function that will now memoized results. 1022 | * @param hashFn Hash function for storing the result of `fn`. 1023 | * @return Memoized version of `fn`. 1024 | **/ 1025 | memoize( 1026 | fn: Function, 1027 | hashFn?: (...args: any[]) => string): Function; 1028 | 1029 | /** 1030 | * Much like setTimeout, invokes function after wait milliseconds. If you pass the optional arguments, 1031 | * they will be forwarded on to the function when it is invoked. 1032 | * @param func Function to delay `waitMS` amount of ms. 1033 | * @param wait The amount of milliseconds to delay `fn`. 1034 | * @arguments Additional arguments to pass to `fn`. 1035 | **/ 1036 | delay( 1037 | func: Function, 1038 | wait: number, 1039 | ...arguments: any[]): any; 1040 | 1041 | /** 1042 | * @see _delay 1043 | **/ 1044 | delay( 1045 | func: Function, 1046 | ...arguments: any[]): any; 1047 | 1048 | /** 1049 | * Defers invoking the function until the current call stack has cleared, similar to using setTimeout 1050 | * with a delay of 0. Useful for performing expensive computations or HTML rendering in chunks without 1051 | * blocking the UI thread from updating. If you pass the optional arguments, they will be forwarded on 1052 | * to the function when it is invoked. 1053 | * @param fn The function to defer. 1054 | * @param arguments Additional arguments to pass to `fn`. 1055 | **/ 1056 | defer( 1057 | fn: Function, 1058 | ...arguments: any[]): void; 1059 | 1060 | /** 1061 | * Creates and returns a new, throttled version of the passed function, that, when invoked repeatedly, 1062 | * will only actually call the original function at most once per every wait milliseconds. Useful for 1063 | * rate-limiting events that occur faster than you can keep up with. 1064 | * By default, throttle will execute the function as soon as you call it for the first time, and, 1065 | * if you call it again any number of times during the wait period, as soon as that period is over. 1066 | * If you'd like to disable the leading-edge call, pass {leading: false}, and if you'd like to disable 1067 | * the execution on the trailing-edge, pass {trailing: false}. 1068 | * @param func Function to throttle `waitMS` ms. 1069 | * @param wait The number of milliseconds to wait before `fn` can be invoked again. 1070 | * @param options Allows for disabling execution of the throttled function on either the leading or trailing edge. 1071 | * @return `fn` with a throttle of `wait`. 1072 | **/ 1073 | throttle( 1074 | func: T, 1075 | wait: number, 1076 | options?: _.ThrottleSettings): T; 1077 | 1078 | /** 1079 | * Creates and returns a new debounced version of the passed function that will postpone its execution 1080 | * until after wait milliseconds have elapsed since the last time it was invoked. Useful for implementing 1081 | * behavior that should only happen after the input has stopped arriving. For example: rendering a preview 1082 | * of a Markdown comment, recalculating a layout after the window has stopped being resized, and so on. 1083 | * 1084 | * Pass true for the immediate parameter to cause debounce to trigger the function on the leading instead 1085 | * of the trailing edge of the wait interval. Useful in circumstances like preventing accidental double 1086 | *-clicks on a "submit" button from firing a second time. 1087 | * @param fn Function to debounce `waitMS` ms. 1088 | * @param wait The number of milliseconds to wait before `fn` can be invoked again. 1089 | * @param immediate True if `fn` should be invoked on the leading edge of `waitMS` instead of the trailing edge. 1090 | * @return Debounced version of `fn` that waits `wait` ms when invoked. 1091 | **/ 1092 | debounce( 1093 | fn: T, 1094 | wait: number, 1095 | immediate?: boolean): T; 1096 | 1097 | /** 1098 | * Creates a version of the function that can only be called one time. Repeated calls to the modified 1099 | * function will have no effect, returning the value from the original call. Useful for initialization 1100 | * functions, instead of having to set a boolean flag and then check it later. 1101 | * @param fn Function to only execute once. 1102 | * @return Copy of `fn` that can only be invoked once. 1103 | **/ 1104 | once(fn: T): T; 1105 | 1106 | /** 1107 | * Creates a version of the function that will only be run after first being called count times. Useful 1108 | * for grouping asynchronous responses, where you want to be sure that all the async calls have finished, 1109 | * before proceeding. 1110 | * @param number count Number of times to be called before actually executing. 1111 | * @param Function fn The function to defer execution `count` times. 1112 | * @return Copy of `fn` that will not execute until it is invoked `count` times. 1113 | **/ 1114 | after( 1115 | count: number, 1116 | fn: Function): Function; 1117 | 1118 | /** 1119 | * Creates a version of the function that can be called no more than count times. The result of 1120 | * the last function call is memoized and returned when count has been reached. 1121 | * @param number count The maxmimum number of times the function can be called. 1122 | * @param Function fn The function to limit the number of times it can be called. 1123 | * @return Copy of `fn` that can only be called `count` times. 1124 | **/ 1125 | before( 1126 | count: number, 1127 | fn: Function): Function; 1128 | 1129 | /** 1130 | * Wraps the first function inside of the wrapper function, passing it as the first argument. This allows 1131 | * the wrapper to execute code before and after the function runs, adjust the arguments, and execute it 1132 | * conditionally. 1133 | * @param fn Function to wrap. 1134 | * @param wrapper The function that will wrap `fn`. 1135 | * @return Wrapped version of `fn. 1136 | **/ 1137 | wrap( 1138 | fn: Function, 1139 | wrapper: (fn: Function, ...args: any[]) => any): Function; 1140 | 1141 | /** 1142 | * Returns a negated version of the pass-in predicate. 1143 | * @param Function predicate 1144 | * @return boolean 1145 | **/ 1146 | negate(predicate: Function): boolean; 1147 | 1148 | /** 1149 | * Returns the composition of a list of functions, where each function consumes the return value of the 1150 | * function that follows. In math terms, composing the functions f(), g(), and h() produces f(g(h())). 1151 | * @param functions List of functions to compose. 1152 | * @return Composition of `functions`. 1153 | **/ 1154 | compose(...functions: Function[]): Function; 1155 | 1156 | /********** 1157 | * Objects * 1158 | ***********/ 1159 | 1160 | /** 1161 | * Retrieve all the names of the object's properties. 1162 | * @param object Retrieve the key or property names from this object. 1163 | * @return List of all the property names on `object`. 1164 | **/ 1165 | keys(object: any): string[]; 1166 | 1167 | /** 1168 | * Return all of the values of the object's properties. 1169 | * @param object Retrieve the values of all the properties on this object. 1170 | * @return List of all the values on `object`. 1171 | **/ 1172 | values(object: any): any[]; 1173 | 1174 | /** 1175 | * Like map, but for objects. Transform the value of each property in turn. 1176 | * @param object The object to transform 1177 | * @param iteratee The function that transforms property values 1178 | * @param context The optional context (value of `this`) to bind to 1179 | * @return a new _.Dictionary of property values 1180 | */ 1181 | mapObject(object: _.Dictionary, iteratee: (val: T, key: string, object: _.Dictionary) => U, context?: any): _.Dictionary; 1182 | 1183 | /** 1184 | * Like map, but for objects. Transform the value of each property in turn. 1185 | * @param object The object to transform 1186 | * @param iteratee The function that tranforms property values 1187 | * @param context The optional context (value of `this`) to bind to 1188 | */ 1189 | mapObject(object: any, iteratee: (val: any, key: string, object: any) => T, context?: any): _.Dictionary; 1190 | 1191 | /** 1192 | * Like map, but for objects. Retrieves a property from each entry in the object, as if by _.property 1193 | * @param object The object to transform 1194 | * @param iteratee The property name to retrieve 1195 | * @param context The optional context (value of `this`) to bind to 1196 | */ 1197 | mapObject(object: any, iteratee: string, context?: any): _.Dictionary; 1198 | 1199 | /** 1200 | * Convert an object into a list of [key, value] pairs. 1201 | * @param object Convert this object to a list of [key, value] pairs. 1202 | * @return List of [key, value] pairs on `object`. 1203 | **/ 1204 | pairs(object: any): any[][]; 1205 | 1206 | /** 1207 | * Returns a copy of the object where the keys have become the values and the values the keys. 1208 | * For this to work, all of your object's values should be unique and string serializable. 1209 | * @param object Object to invert key/value pairs. 1210 | * @return An inverted key/value paired version of `object`. 1211 | **/ 1212 | invert(object: any): any; 1213 | 1214 | /** 1215 | * Returns a sorted list of the names of every method in an object - that is to say, 1216 | * the name of every function property of the object. 1217 | * @param object Object to pluck all function property names from. 1218 | * @return List of all the function names on `object`. 1219 | **/ 1220 | functions(object: any): string[]; 1221 | 1222 | /** 1223 | * @see _functions 1224 | **/ 1225 | methods(object: any): string[]; 1226 | 1227 | /** 1228 | * Copy all of the properties in the source objects over to the destination object, and return 1229 | * the destination object. It's in-order, so the last source will override properties of the 1230 | * same name in previous arguments. 1231 | * @param destination Object to extend all the properties from `sources`. 1232 | * @param sources Extends `destination` with all properties from these source objects. 1233 | * @return `destination` extended with all the properties from the `sources` objects. 1234 | **/ 1235 | extend( 1236 | destination: any, 1237 | ...sources: any[]): any; 1238 | 1239 | /** 1240 | * Like extend, but only copies own properties over to the destination object. (alias: assign) 1241 | */ 1242 | extendOwn( 1243 | destination: any, 1244 | ...source: any[]): any; 1245 | 1246 | /** 1247 | * Like extend, but only copies own properties over to the destination object. (alias: extendOwn) 1248 | */ 1249 | assign( 1250 | destination: any, 1251 | ...source: any[]): any; 1252 | 1253 | /** 1254 | * Return a copy of the object, filtered to only have values for the whitelisted keys 1255 | * (or array of valid keys). 1256 | * @param object Object to strip unwanted key/value pairs. 1257 | * @keys The key/value pairs to keep on `object`. 1258 | * @return Copy of `object` with only the `keys` properties. 1259 | **/ 1260 | pick( 1261 | object: any, 1262 | ...keys: any[]): any; 1263 | 1264 | /** 1265 | * @see _.pick 1266 | **/ 1267 | pick( 1268 | object: any, 1269 | fn: (value: any, key: any, object: any) => any): any; 1270 | 1271 | /** 1272 | * Return a copy of the object, filtered to omit the blacklisted keys (or array of keys). 1273 | * @param object Object to strip unwanted key/value pairs. 1274 | * @param keys The key/value pairs to remove on `object`. 1275 | * @return Copy of `object` without the `keys` properties. 1276 | **/ 1277 | omit( 1278 | object: any, 1279 | ...keys: string[]): any; 1280 | 1281 | /** 1282 | * @see _.omit 1283 | **/ 1284 | omit( 1285 | object: any, 1286 | keys: string[]): any; 1287 | 1288 | /** 1289 | * @see _.omit 1290 | **/ 1291 | omit( 1292 | object: any, 1293 | iteratee: Function): any; 1294 | 1295 | /** 1296 | * Fill in null and undefined properties in object with values from the defaults objects, 1297 | * and return the object. As soon as the property is filled, further defaults will have no effect. 1298 | * @param object Fill this object with default values. 1299 | * @param defaults The default values to add to `object`. 1300 | * @return `object` with added `defaults` values. 1301 | **/ 1302 | defaults( 1303 | object: any, 1304 | ...defaults: any[]): any; 1305 | 1306 | /** 1307 | * Create a shallow-copied clone of the object. 1308 | * Any nested objects or arrays will be copied by reference, not duplicated. 1309 | * @param object Object to clone. 1310 | * @return Copy of `object`. 1311 | **/ 1312 | clone(object: T): T; 1313 | 1314 | /** 1315 | * Invokes interceptor with the object, and then returns object. The primary purpose of this method 1316 | * is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. 1317 | * @param object Argument to `interceptor`. 1318 | * @param intercepter The function to modify `object` before continuing the method chain. 1319 | * @return Modified `object`. 1320 | **/ 1321 | tap(object: T, intercepter: Function): T; 1322 | 1323 | /** 1324 | * Does the object contain the given key? Identical to object.hasOwnProperty(key), but uses a safe 1325 | * reference to the hasOwnProperty function, in case it's been overridden accidentally. 1326 | * @param object Object to check for `key`. 1327 | * @param key The key to check for on `object`. 1328 | * @return True if `key` is a property on `object`, otherwise false. 1329 | **/ 1330 | has(object: any, key: string): boolean; 1331 | 1332 | /** 1333 | * Returns a predicate function that will tell you if a passed in object contains all of the key/value properties present in attrs. 1334 | * @param attrs Object with key values pair 1335 | * @return Predicate function 1336 | **/ 1337 | matches(attrs: T): _.ListIterator; 1338 | 1339 | /** 1340 | * Returns a function that will itself return the key property of any passed-in object. 1341 | * @param key Property of the object. 1342 | * @return Function which accept an object an returns the value of key in that object. 1343 | **/ 1344 | property(key: string): (object: Object) => any; 1345 | 1346 | /** 1347 | * Performs an optimized deep comparison between the two objects, 1348 | * to determine if they should be considered equal. 1349 | * @param object Compare to `other`. 1350 | * @param other Compare to `object`. 1351 | * @return True if `object` is equal to `other`. 1352 | **/ 1353 | isEqual(object: any, other: any): boolean; 1354 | 1355 | /** 1356 | * Returns true if object contains no values. 1357 | * @param object Check if this object has no properties or values. 1358 | * @return True if `object` is empty. 1359 | **/ 1360 | isEmpty(object: any): boolean; 1361 | 1362 | /** 1363 | * Returns true if object is a DOM element. 1364 | * @param object Check if this object is a DOM element. 1365 | * @return True if `object` is a DOM element, otherwise false. 1366 | **/ 1367 | isElement(object: any): boolean; 1368 | 1369 | /** 1370 | * Returns true if object is an Array. 1371 | * @param object Check if this object is an Array. 1372 | * @return True if `object` is an Array, otherwise false. 1373 | **/ 1374 | isArray(object: any): boolean; 1375 | 1376 | /** 1377 | * Returns true if value is an Object. Note that JavaScript arrays and functions are objects, 1378 | * while (normal) strings and numbers are not. 1379 | * @param object Check if this object is an Object. 1380 | * @return True of `object` is an Object, otherwise false. 1381 | **/ 1382 | isObject(object: any): boolean; 1383 | 1384 | /** 1385 | * Returns true if object is an Arguments object. 1386 | * @param object Check if this object is an Arguments object. 1387 | * @return True if `object` is an Arguments object, otherwise false. 1388 | **/ 1389 | isArguments(object: any): boolean; 1390 | 1391 | /** 1392 | * Returns true if object is a Function. 1393 | * @param object Check if this object is a Function. 1394 | * @return True if `object` is a Function, otherwise false. 1395 | **/ 1396 | isFunction(object: any): boolean; 1397 | 1398 | /** 1399 | * Returns true if object is a String. 1400 | * @param object Check if this object is a String. 1401 | * @return True if `object` is a String, otherwise false. 1402 | **/ 1403 | isString(object: any): boolean; 1404 | 1405 | /** 1406 | * Returns true if object is a Number (including NaN). 1407 | * @param object Check if this object is a Number. 1408 | * @return True if `object` is a Number, otherwise false. 1409 | **/ 1410 | isNumber(object: any): boolean; 1411 | 1412 | /** 1413 | * Returns true if object is a finite Number. 1414 | * @param object Check if this object is a finite Number. 1415 | * @return True if `object` is a finite Number. 1416 | **/ 1417 | isFinite(object: any): boolean; 1418 | 1419 | /** 1420 | * Returns true if object is either true or false. 1421 | * @param object Check if this object is a bool. 1422 | * @return True if `object` is a bool, otherwise false. 1423 | **/ 1424 | isBoolean(object: any): boolean; 1425 | 1426 | /** 1427 | * Returns true if object is a Date. 1428 | * @param object Check if this object is a Date. 1429 | * @return True if `object` is a Date, otherwise false. 1430 | **/ 1431 | isDate(object: any): boolean; 1432 | 1433 | /** 1434 | * Returns true if object is a RegExp. 1435 | * @param object Check if this object is a RegExp. 1436 | * @return True if `object` is a RegExp, otherwise false. 1437 | **/ 1438 | isRegExp(object: any): boolean; 1439 | 1440 | /** 1441 | * Returns true if object is NaN. 1442 | * Note: this is not the same as the native isNaN function, 1443 | * which will also return true if the variable is undefined. 1444 | * @param object Check if this object is NaN. 1445 | * @return True if `object` is NaN, otherwise false. 1446 | **/ 1447 | isNaN(object: any): boolean; 1448 | 1449 | /** 1450 | * Returns true if the value of object is null. 1451 | * @param object Check if this object is null. 1452 | * @return True if `object` is null, otherwise false. 1453 | **/ 1454 | isNull(object: any): boolean; 1455 | 1456 | /** 1457 | * Returns true if value is undefined. 1458 | * @param object Check if this object is undefined. 1459 | * @return True if `object` is undefined, otherwise false. 1460 | **/ 1461 | isUndefined(value: any): boolean; 1462 | 1463 | /* ********* 1464 | * Utility * 1465 | ********** */ 1466 | 1467 | /** 1468 | * Give control of the "_" variable back to its previous owner. 1469 | * Returns a reference to the Underscore object. 1470 | * @return Underscore object reference. 1471 | **/ 1472 | noConflict(): any; 1473 | 1474 | /** 1475 | * Returns the same value that is used as the argument. In math: f(x) = x 1476 | * This function looks useless, but is used throughout Underscore as a default iterator. 1477 | * @param value Identity of this object. 1478 | * @return `value`. 1479 | **/ 1480 | identity(value: T): T; 1481 | 1482 | /** 1483 | * Creates a function that returns the same value that is used as the argument of _.constant 1484 | * @param value Identity of this object. 1485 | * @return Function that return value. 1486 | **/ 1487 | constant(value: T): () => T; 1488 | 1489 | /** 1490 | * Returns undefined irrespective of the arguments passed to it. Useful as the default 1491 | * for optional callback arguments. 1492 | * Note there is no way to indicate a 'undefined' return, so it is currently typed as void. 1493 | * @return undefined 1494 | **/ 1495 | noop(): void; 1496 | 1497 | /** 1498 | * Invokes the given iterator function n times. 1499 | * Each invocation of iterator is called with an index argument 1500 | * @param n Number of times to invoke `iterator`. 1501 | * @param iterator Function iterator to invoke `n` times. 1502 | * @param context `this` object in `iterator`, optional. 1503 | **/ 1504 | times(n: number, iterator: (n: number) => TResult, context?: any): TResult[]; 1505 | 1506 | /** 1507 | * Returns a random integer between min and max, inclusive. If you only pass one argument, 1508 | * it will return a number between 0 and that number. 1509 | * @param max The maximum random number. 1510 | * @return A random number between 0 and `max`. 1511 | **/ 1512 | random(max: number): number; 1513 | 1514 | /** 1515 | * @see _.random 1516 | * @param min The minimum random number. 1517 | * @return A random number between `min` and `max`. 1518 | **/ 1519 | random(min: number, max: number): number; 1520 | 1521 | /** 1522 | * Allows you to extend Underscore with your own utility functions. Pass a hash of 1523 | * {name: function} definitions to have your functions added to the Underscore object, 1524 | * as well as the OOP wrapper. 1525 | * @param object Mixin object containing key/function pairs to add to the Underscore object. 1526 | **/ 1527 | mixin(object: any): void; 1528 | 1529 | /** 1530 | * A mostly-internal function to generate callbacks that can be applied to each element 1531 | * in a collection, returning the desired result -- either identity, an arbitrary callback, 1532 | * a property matcher, or a propetery accessor. 1533 | * @param string|Function|Object value The value to iterate over, usually the key. 1534 | * @param any context 1535 | * @param number argCount 1536 | * @return Callback that can be applied to each element in a collection. 1537 | **/ 1538 | iteratee(value: string): Function; 1539 | iteratee(value: Function, context?: any, argCount?: number): Function; 1540 | iteratee(value: Object): Function; 1541 | 1542 | /** 1543 | * Generate a globally-unique id for client-side models or DOM elements that need one. 1544 | * If prefix is passed, the id will be appended to it. Without prefix, returns an integer. 1545 | * @param prefix A prefix string to start the unique ID with. 1546 | * @return Unique string ID beginning with `prefix`. 1547 | **/ 1548 | uniqueId(prefix: string): string; 1549 | 1550 | /** 1551 | * @see _.uniqueId 1552 | **/ 1553 | uniqueId(): number; 1554 | 1555 | /** 1556 | * Escapes a string for insertion into HTML, replacing &, <, >, ", ', and / characters. 1557 | * @param str Raw string to escape. 1558 | * @return `str` HTML escaped. 1559 | **/ 1560 | escape(str: string): string; 1561 | 1562 | /** 1563 | * The opposite of escape, replaces &, <, >, ", and ' with their unescaped counterparts. 1564 | * @param str HTML escaped string. 1565 | * @return `str` Raw string. 1566 | **/ 1567 | unescape(str: string): string; 1568 | 1569 | /** 1570 | * If the value of the named property is a function then invoke it; otherwise, return it. 1571 | * @param object Object to maybe invoke function `property` on. 1572 | * @param property The function by name to invoke on `object`. 1573 | * @return The result of invoking the function `property` on `object. 1574 | **/ 1575 | result(object: any, property: string): any; 1576 | 1577 | /** 1578 | * Compiles JavaScript templates into functions that can be evaluated for rendering. Useful 1579 | * for rendering complicated bits of HTML from JSON data sources. Template functions can both 1580 | * interpolate variables, using <%= ... %>, as well as execute arbitrary JavaScript code, with 1581 | * <% ... %>. If you wish to interpolate a value, and have it be HTML-escaped, use <%- ... %> When 1582 | * you evaluate a template function, pass in a data object that has properties corresponding to 1583 | * the template's free variables. If you're writing a one-off, you can pass the data object as 1584 | * the second parameter to template in order to render immediately instead of returning a template 1585 | * function. The settings argument should be a hash containing any _.templateSettings that should 1586 | * be overridden. 1587 | * @param templateString Underscore HTML template. 1588 | * @param data Data to use when compiling `templateString`. 1589 | * @param settings Settings to use while compiling. 1590 | * @return Returns the compiled Underscore HTML template. 1591 | **/ 1592 | template(templateString: string, settings?: _.TemplateSettings): (...data: any[]) => string; 1593 | 1594 | /** 1595 | * By default, Underscore uses ERB-style template delimiters, change the 1596 | * following template settings to use alternative delimiters. 1597 | **/ 1598 | templateSettings: _.TemplateSettings; 1599 | 1600 | /** 1601 | * Returns an integer timestamp for the current time, using the fastest method available in the runtime. Useful for implementing timing/animation functions. 1602 | **/ 1603 | now(): number; 1604 | 1605 | /* ********** 1606 | * Chaining * 1607 | *********** */ 1608 | 1609 | /** 1610 | * Returns a wrapped object. Calling methods on this object will continue to return wrapped objects 1611 | * until value() is used. 1612 | * @param obj Object to chain. 1613 | * @return Wrapped `obj`. 1614 | **/ 1615 | chain(obj: T[]): _Chain; 1616 | chain(obj: T): _Chain; 1617 | } 1618 | 1619 | interface Underscore { 1620 | 1621 | /* ************* 1622 | * Collections * 1623 | ************* */ 1624 | 1625 | /** 1626 | * Wrapped type `any[]`. 1627 | * @see _.each 1628 | **/ 1629 | each(iterator: _.ListIterator, context?: any): T[]; 1630 | 1631 | /** 1632 | * @see _.each 1633 | **/ 1634 | each(iterator: _.ObjectIterator, context?: any): T[]; 1635 | 1636 | /** 1637 | * @see _.each 1638 | **/ 1639 | forEach(iterator: _.ListIterator, context?: any): T[]; 1640 | 1641 | /** 1642 | * @see _.each 1643 | **/ 1644 | forEach(iterator: _.ObjectIterator, context?: any): T[]; 1645 | 1646 | /** 1647 | * Wrapped type `any[]`. 1648 | * @see _.map 1649 | **/ 1650 | map(iterator: _.ListIterator, context?: any): TResult[]; 1651 | 1652 | /** 1653 | * Wrapped type `any[]`. 1654 | * @see _.map 1655 | **/ 1656 | map(iterator: _.ObjectIterator, context?: any): TResult[]; 1657 | 1658 | /** 1659 | * @see _.map 1660 | **/ 1661 | collect(iterator: _.ListIterator, context?: any): TResult[]; 1662 | 1663 | /** 1664 | * @see _.map 1665 | **/ 1666 | collect(iterator: _.ObjectIterator, context?: any): TResult[]; 1667 | 1668 | /** 1669 | * Wrapped type `any[]`. 1670 | * @see _.reduce 1671 | **/ 1672 | reduce(iterator: _.MemoIterator, memo?: TResult, context?: any): TResult; 1673 | 1674 | /** 1675 | * @see _.reduce 1676 | **/ 1677 | inject(iterator: _.MemoIterator, memo?: TResult, context?: any): TResult; 1678 | 1679 | /** 1680 | * @see _.reduce 1681 | **/ 1682 | foldl(iterator: _.MemoIterator, memo?: TResult, context?: any): TResult; 1683 | 1684 | /** 1685 | * Wrapped type `any[]`. 1686 | * @see _.reduceRight 1687 | **/ 1688 | reduceRight(iterator: _.MemoIterator, memo?: TResult, context?: any): TResult; 1689 | 1690 | /** 1691 | * @see _.reduceRight 1692 | **/ 1693 | foldr(iterator: _.MemoIterator, memo?: TResult, context?: any): TResult; 1694 | 1695 | /** 1696 | * Wrapped type `any[]`. 1697 | * @see _.find 1698 | **/ 1699 | find(iterator: _.ListIterator, context?: any): T; 1700 | 1701 | /** 1702 | * @see _.find 1703 | **/ 1704 | detect(iterator: _.ListIterator, context?: any): T; 1705 | 1706 | /** 1707 | * Wrapped type `any[]`. 1708 | * @see _.filter 1709 | **/ 1710 | filter(iterator: _.ListIterator, context?: any): T[]; 1711 | 1712 | /** 1713 | * @see _.filter 1714 | **/ 1715 | select(iterator: _.ListIterator, context?: any): T[]; 1716 | 1717 | /** 1718 | * Wrapped type `any[]`. 1719 | * @see _.where 1720 | **/ 1721 | where(properties: U): T[]; 1722 | 1723 | /** 1724 | * Wrapped type `any[]`. 1725 | * @see _.findWhere 1726 | **/ 1727 | findWhere(properties: U): T; 1728 | 1729 | /** 1730 | * Wrapped type `any[]`. 1731 | * @see _.reject 1732 | **/ 1733 | reject(iterator: _.ListIterator, context?: any): T[]; 1734 | 1735 | /** 1736 | * Wrapped type `any[]`. 1737 | * @see _.all 1738 | **/ 1739 | all(iterator?: _.ListIterator, context?: any): boolean; 1740 | 1741 | /** 1742 | * @see _.all 1743 | **/ 1744 | every(iterator?: _.ListIterator, context?: any): boolean; 1745 | 1746 | /** 1747 | * Wrapped type `any[]`. 1748 | * @see _.any 1749 | **/ 1750 | any(iterator?: _.ListIterator, context?: any): boolean; 1751 | 1752 | /** 1753 | * @see _.any 1754 | **/ 1755 | some(iterator?: _.ListIterator, context?: any): boolean; 1756 | 1757 | /** 1758 | * Wrapped type `any[]`. 1759 | * @see _.contains 1760 | **/ 1761 | contains(value: T): boolean; 1762 | 1763 | /** 1764 | * Alias for 'contains'. 1765 | * @see contains 1766 | **/ 1767 | include(value: T): boolean; 1768 | 1769 | /** 1770 | * Wrapped type `any[]`. 1771 | * @see _.invoke 1772 | **/ 1773 | invoke(methodName: string, ...arguments: any[]): any; 1774 | 1775 | /** 1776 | * Wrapped type `any[]`. 1777 | * @see _.pluck 1778 | **/ 1779 | pluck(propertyName: string): any[]; 1780 | 1781 | /** 1782 | * Wrapped type `number[]`. 1783 | * @see _.max 1784 | **/ 1785 | max(): number; 1786 | 1787 | /** 1788 | * Wrapped type `any[]`. 1789 | * @see _.max 1790 | **/ 1791 | max(iterator: _.ListIterator, context?: any): T; 1792 | 1793 | /** 1794 | * Wrapped type `any[]`. 1795 | * @see _.max 1796 | **/ 1797 | max(iterator?: _.ListIterator, context?: any): T; 1798 | 1799 | /** 1800 | * Wrapped type `number[]`. 1801 | * @see _.min 1802 | **/ 1803 | min(): number; 1804 | 1805 | /** 1806 | * Wrapped type `any[]`. 1807 | * @see _.min 1808 | **/ 1809 | min(iterator: _.ListIterator, context?: any): T; 1810 | 1811 | /** 1812 | * Wrapped type `any[]`. 1813 | * @see _.min 1814 | **/ 1815 | min(iterator?: _.ListIterator, context?: any): T; 1816 | 1817 | /** 1818 | * Wrapped type `any[]`. 1819 | * @see _.sortBy 1820 | **/ 1821 | sortBy(iterator?: _.ListIterator, context?: any): T[]; 1822 | 1823 | /** 1824 | * Wrapped type `any[]`. 1825 | * @see _.sortBy 1826 | **/ 1827 | sortBy(iterator: string, context?: any): T[]; 1828 | 1829 | /** 1830 | * Wrapped type `any[]`. 1831 | * @see _.groupBy 1832 | **/ 1833 | groupBy(iterator?: _.ListIterator, context?: any): _.Dictionary<_.List>; 1834 | 1835 | /** 1836 | * Wrapped type `any[]`. 1837 | * @see _.groupBy 1838 | **/ 1839 | groupBy(iterator: string, context?: any): _.Dictionary; 1840 | 1841 | /** 1842 | * Wrapped type `any[]`. 1843 | * @see _.indexBy 1844 | **/ 1845 | indexBy(iterator: _.ListIterator, context?: any): _.Dictionary; 1846 | 1847 | /** 1848 | * Wrapped type `any[]`. 1849 | * @see _.indexBy 1850 | **/ 1851 | indexBy(iterator: string, context?: any): _.Dictionary; 1852 | 1853 | /** 1854 | * Wrapped type `any[]`. 1855 | * @see _.countBy 1856 | **/ 1857 | countBy(iterator?: _.ListIterator, context?: any): _.Dictionary; 1858 | 1859 | /** 1860 | * Wrapped type `any[]`. 1861 | * @see _.countBy 1862 | **/ 1863 | countBy(iterator: string, context?: any): _.Dictionary; 1864 | 1865 | /** 1866 | * Wrapped type `any[]`. 1867 | * @see _.shuffle 1868 | **/ 1869 | shuffle(): T[]; 1870 | 1871 | /** 1872 | * Wrapped type `any[]`. 1873 | * @see _.sample 1874 | **/ 1875 | sample(n: number): T[]; 1876 | 1877 | /** 1878 | * @see _.sample 1879 | **/ 1880 | sample(): T; 1881 | 1882 | /** 1883 | * Wrapped type `any`. 1884 | * @see _.toArray 1885 | **/ 1886 | toArray(): T[]; 1887 | 1888 | /** 1889 | * Wrapped type `any`. 1890 | * @see _.size 1891 | **/ 1892 | size(): number; 1893 | 1894 | /********* 1895 | * Arrays * 1896 | **********/ 1897 | 1898 | /** 1899 | * Wrapped type `any[]`. 1900 | * @see _.first 1901 | **/ 1902 | first(): T; 1903 | 1904 | /** 1905 | * Wrapped type `any[]`. 1906 | * @see _.first 1907 | **/ 1908 | first(n: number): T[]; 1909 | 1910 | /** 1911 | * @see _.first 1912 | **/ 1913 | head(): T; 1914 | 1915 | /** 1916 | * @see _.first 1917 | **/ 1918 | head(n: number): T[]; 1919 | 1920 | /** 1921 | * @see _.first 1922 | **/ 1923 | take(): T; 1924 | 1925 | /** 1926 | * @see _.first 1927 | **/ 1928 | take(n: number): T[]; 1929 | 1930 | /** 1931 | * Wrapped type `any[]`. 1932 | * @see _.initial 1933 | **/ 1934 | initial(n?: number): T[]; 1935 | 1936 | /** 1937 | * Wrapped type `any[]`. 1938 | * @see _.last 1939 | **/ 1940 | last(): T; 1941 | 1942 | /** 1943 | * Wrapped type `any[]`. 1944 | * @see _.last 1945 | **/ 1946 | last(n: number): T[]; 1947 | 1948 | /** 1949 | * Wrapped type `any[]`. 1950 | * @see _.rest 1951 | **/ 1952 | rest(n?: number): T[]; 1953 | 1954 | /** 1955 | * @see _.rest 1956 | **/ 1957 | tail(n?: number): T[]; 1958 | 1959 | /** 1960 | * @see _.rest 1961 | **/ 1962 | drop(n?: number): T[]; 1963 | 1964 | /** 1965 | * Wrapped type `any[]`. 1966 | * @see _.compact 1967 | **/ 1968 | compact(): T[]; 1969 | 1970 | /** 1971 | * Wrapped type `any`. 1972 | * @see _.flatten 1973 | **/ 1974 | flatten(shallow?: boolean): any[]; 1975 | 1976 | /** 1977 | * Wrapped type `any[]`. 1978 | * @see _.without 1979 | **/ 1980 | without(...values: T[]): T[]; 1981 | 1982 | /** 1983 | * Wrapped type `any[]`. 1984 | * @see _.partition 1985 | **/ 1986 | partition(iterator: _.ListIterator, context?: any): T[][]; 1987 | 1988 | /** 1989 | * Wrapped type `any[][]`. 1990 | * @see _.union 1991 | **/ 1992 | union(...arrays: _.List[]): T[]; 1993 | 1994 | /** 1995 | * Wrapped type `any[][]`. 1996 | * @see _.intersection 1997 | **/ 1998 | intersection(...arrays: _.List[]): T[]; 1999 | 2000 | /** 2001 | * Wrapped type `any[]`. 2002 | * @see _.difference 2003 | **/ 2004 | difference(...others: _.List[]): T[]; 2005 | 2006 | /** 2007 | * Wrapped type `any[]`. 2008 | * @see _.uniq 2009 | **/ 2010 | uniq(isSorted?: boolean, iterator?: _.ListIterator): T[]; 2011 | 2012 | /** 2013 | * Wrapped type `any[]`. 2014 | * @see _.uniq 2015 | **/ 2016 | uniq(iterator?: _.ListIterator, context?: any): T[]; 2017 | 2018 | /** 2019 | * @see _.uniq 2020 | **/ 2021 | unique(isSorted?: boolean, iterator?: _.ListIterator): T[]; 2022 | 2023 | /** 2024 | * @see _.uniq 2025 | **/ 2026 | unique(iterator?: _.ListIterator, context?: any): T[]; 2027 | 2028 | /** 2029 | * Wrapped type `any[][]`. 2030 | * @see _.zip 2031 | **/ 2032 | zip(...arrays: any[][]): any[][]; 2033 | 2034 | /** 2035 | * Wrapped type `any[][]`. 2036 | * @see _.object 2037 | **/ 2038 | object(...keyValuePairs: any[][]): any; 2039 | 2040 | /** 2041 | * @see _.object 2042 | **/ 2043 | object(values?: any): any; 2044 | 2045 | /** 2046 | * Wrapped type `any[]`. 2047 | * @see _.indexOf 2048 | **/ 2049 | indexOf(value: T, isSorted?: boolean): number; 2050 | 2051 | /** 2052 | * @see _.indexOf 2053 | **/ 2054 | indexOf(value: T, startFrom: number): number; 2055 | 2056 | /** 2057 | * Wrapped type `any[]`. 2058 | * @see _.lastIndexOf 2059 | **/ 2060 | lastIndexOf(value: T, from?: number): number; 2061 | 2062 | /** 2063 | * Wrapped type `any[]`. 2064 | * @see _.sortedIndex 2065 | **/ 2066 | sortedIndex(value: T, iterator?: (x: T) => any, context?: any): number; 2067 | 2068 | /** 2069 | * Wrapped type `number`. 2070 | * @see _.range 2071 | **/ 2072 | range(stop: number, step?: number): number[]; 2073 | 2074 | /** 2075 | * Wrapped type `number`. 2076 | * @see _.range 2077 | **/ 2078 | range(): number[]; 2079 | 2080 | /* *********** 2081 | * Functions * 2082 | ************ */ 2083 | 2084 | /** 2085 | * Wrapped type `Function`. 2086 | * @see _.bind 2087 | **/ 2088 | bind(object: any, ...arguments: any[]): Function; 2089 | 2090 | /** 2091 | * Wrapped type `object`. 2092 | * @see _.bindAll 2093 | **/ 2094 | bindAll(...methodNames: string[]): any; 2095 | 2096 | /** 2097 | * Wrapped type `Function`. 2098 | * @see _.partial 2099 | **/ 2100 | partial(...arguments: any[]): Function; 2101 | 2102 | /** 2103 | * Wrapped type `Function`. 2104 | * @see _.memoize 2105 | **/ 2106 | memoize(hashFn?: (n: any) => string): Function; 2107 | 2108 | /** 2109 | * Wrapped type `Function`. 2110 | * @see _.defer 2111 | **/ 2112 | defer(...arguments: any[]): void; 2113 | 2114 | /** 2115 | * Wrapped type `Function`. 2116 | * @see _.delay 2117 | **/ 2118 | delay(wait: number, ...arguments: any[]): any; 2119 | 2120 | /** 2121 | * @see _.delay 2122 | **/ 2123 | delay(...arguments: any[]): any; 2124 | 2125 | /** 2126 | * Wrapped type `Function`. 2127 | * @see _.throttle 2128 | **/ 2129 | throttle(wait: number, options?: _.ThrottleSettings): Function; 2130 | 2131 | /** 2132 | * Wrapped type `Function`. 2133 | * @see _.debounce 2134 | **/ 2135 | debounce(wait: number, immediate?: boolean): Function; 2136 | 2137 | /** 2138 | * Wrapped type `Function`. 2139 | * @see _.once 2140 | **/ 2141 | once(): Function; 2142 | 2143 | /** 2144 | * Wrapped type `number`. 2145 | * @see _.after 2146 | **/ 2147 | after(fn: Function): Function; 2148 | 2149 | /** 2150 | * Wrapped type `number`. 2151 | * @see _.before 2152 | **/ 2153 | before(fn: Function): Function; 2154 | 2155 | /** 2156 | * Wrapped type `Function`. 2157 | * @see _.wrap 2158 | **/ 2159 | wrap(wrapper: Function): () => Function; 2160 | 2161 | /** 2162 | * Wrapped type `Function`. 2163 | * @see _.negate 2164 | **/ 2165 | negate(): boolean; 2166 | 2167 | /** 2168 | * Wrapped type `Function[]`. 2169 | * @see _.compose 2170 | **/ 2171 | compose(...functions: Function[]): Function; 2172 | 2173 | /********* * 2174 | * Objects * 2175 | ********** */ 2176 | 2177 | /** 2178 | * Wrapped type `object`. 2179 | * @see _.keys 2180 | **/ 2181 | keys(): string[]; 2182 | 2183 | /** 2184 | * Wrapped type `object`. 2185 | * @see _.values 2186 | **/ 2187 | values(): T[]; 2188 | 2189 | /** 2190 | * Wrapped type `object`. 2191 | * @see _.pairs 2192 | **/ 2193 | pairs(): any[][]; 2194 | 2195 | /** 2196 | * Wrapped type `object`. 2197 | * @see _.invert 2198 | **/ 2199 | invert(): any; 2200 | 2201 | /** 2202 | * Wrapped type `object`. 2203 | * @see _.functions 2204 | **/ 2205 | functions(): string[]; 2206 | 2207 | /** 2208 | * @see _.functions 2209 | **/ 2210 | methods(): string[]; 2211 | 2212 | /** 2213 | * Wrapped type `object`. 2214 | * @see _.extend 2215 | **/ 2216 | extend(...sources: any[]): any; 2217 | 2218 | /** 2219 | * Wrapped type `object`. 2220 | * @see _.pick 2221 | **/ 2222 | pick(...keys: any[]): any; 2223 | pick(keys: any[]): any; 2224 | pick(fn: (value: any, key: any, object: any) => any): any; 2225 | 2226 | /** 2227 | * Wrapped type `object`. 2228 | * @see _.omit 2229 | **/ 2230 | omit(...keys: string[]): any; 2231 | omit(keys: string[]): any; 2232 | omit(fn: Function): any; 2233 | 2234 | /** 2235 | * Wrapped type `object`. 2236 | * @see _.defaults 2237 | **/ 2238 | defaults(...defaults: any[]): any; 2239 | 2240 | /** 2241 | * Wrapped type `any[]`. 2242 | * @see _.clone 2243 | **/ 2244 | clone(): T; 2245 | 2246 | /** 2247 | * Wrapped type `object`. 2248 | * @see _.tap 2249 | **/ 2250 | tap(interceptor: (...as: any[]) => any): any; 2251 | 2252 | /** 2253 | * Wrapped type `object`. 2254 | * @see _.has 2255 | **/ 2256 | has(key: string): boolean; 2257 | 2258 | /** 2259 | * Wrapped type `any[]`. 2260 | * @see _.matches 2261 | **/ 2262 | matches(): _.ListIterator; 2263 | 2264 | /** 2265 | * Wrapped type `string`. 2266 | * @see _.property 2267 | **/ 2268 | property(): (object: Object) => any; 2269 | 2270 | /** 2271 | * Wrapped type `object`. 2272 | * @see _.isEqual 2273 | **/ 2274 | isEqual(other: any): boolean; 2275 | 2276 | /** 2277 | * Wrapped type `object`. 2278 | * @see _.isEmpty 2279 | **/ 2280 | isEmpty(): boolean; 2281 | 2282 | /** 2283 | * Wrapped type `object`. 2284 | * @see _.isElement 2285 | **/ 2286 | isElement(): boolean; 2287 | 2288 | /** 2289 | * Wrapped type `object`. 2290 | * @see _.isArray 2291 | **/ 2292 | isArray(): boolean; 2293 | 2294 | /** 2295 | * Wrapped type `object`. 2296 | * @see _.isObject 2297 | **/ 2298 | isObject(): boolean; 2299 | 2300 | /** 2301 | * Wrapped type `object`. 2302 | * @see _.isArguments 2303 | **/ 2304 | isArguments(): boolean; 2305 | 2306 | /** 2307 | * Wrapped type `object`. 2308 | * @see _.isFunction 2309 | **/ 2310 | isFunction(): boolean; 2311 | 2312 | /** 2313 | * Wrapped type `object`. 2314 | * @see _.isString 2315 | **/ 2316 | isString(): boolean; 2317 | 2318 | /** 2319 | * Wrapped type `object`. 2320 | * @see _.isNumber 2321 | **/ 2322 | isNumber(): boolean; 2323 | 2324 | /** 2325 | * Wrapped type `object`. 2326 | * @see _.isFinite 2327 | **/ 2328 | isFinite(): boolean; 2329 | 2330 | /** 2331 | * Wrapped type `object`. 2332 | * @see _.isBoolean 2333 | **/ 2334 | isBoolean(): boolean; 2335 | 2336 | /** 2337 | * Wrapped type `object`. 2338 | * @see _.isDate 2339 | **/ 2340 | isDate(): boolean; 2341 | 2342 | /** 2343 | * Wrapped type `object`. 2344 | * @see _.isRegExp 2345 | **/ 2346 | isRegExp(): boolean; 2347 | 2348 | /** 2349 | * Wrapped type `object`. 2350 | * @see _.isNaN 2351 | **/ 2352 | isNaN(): boolean; 2353 | 2354 | /** 2355 | * Wrapped type `object`. 2356 | * @see _.isNull 2357 | **/ 2358 | isNull(): boolean; 2359 | 2360 | /** 2361 | * Wrapped type `object`. 2362 | * @see _.isUndefined 2363 | **/ 2364 | isUndefined(): boolean; 2365 | 2366 | /********* * 2367 | * Utility * 2368 | ********** */ 2369 | 2370 | /** 2371 | * Wrapped type `any`. 2372 | * @see _.identity 2373 | **/ 2374 | identity(): any; 2375 | 2376 | /** 2377 | * Wrapped type `any`. 2378 | * @see _.constant 2379 | **/ 2380 | constant(): () => T; 2381 | 2382 | /** 2383 | * Wrapped type `any`. 2384 | * @see _.noop 2385 | **/ 2386 | noop(): void; 2387 | 2388 | /** 2389 | * Wrapped type `number`. 2390 | * @see _.times 2391 | **/ 2392 | times(iterator: (n: number) => TResult, context?: any): TResult[]; 2393 | 2394 | /** 2395 | * Wrapped type `number`. 2396 | * @see _.random 2397 | **/ 2398 | random(): number; 2399 | /** 2400 | * Wrapped type `number`. 2401 | * @see _.random 2402 | **/ 2403 | random(max: number): number; 2404 | 2405 | /** 2406 | * Wrapped type `object`. 2407 | * @see _.mixin 2408 | **/ 2409 | mixin(): void; 2410 | 2411 | /** 2412 | * Wrapped type `string|Function|Object`. 2413 | * @see _.iteratee 2414 | **/ 2415 | iteratee(context?: any, argCount?: number): Function; 2416 | 2417 | /** 2418 | * Wrapped type `string`. 2419 | * @see _.uniqueId 2420 | **/ 2421 | uniqueId(): string; 2422 | 2423 | /** 2424 | * Wrapped type `string`. 2425 | * @see _.escape 2426 | **/ 2427 | escape(): string; 2428 | 2429 | /** 2430 | * Wrapped type `string`. 2431 | * @see _.unescape 2432 | **/ 2433 | unescape(): string; 2434 | 2435 | /** 2436 | * Wrapped type `object`. 2437 | * @see _.result 2438 | **/ 2439 | result(property: string): any; 2440 | 2441 | /** 2442 | * Wrapped type `string`. 2443 | * @see _.template 2444 | **/ 2445 | template(settings?: _.TemplateSettings): (...data: any[]) => string; 2446 | 2447 | /********** * 2448 | * Chaining * 2449 | *********** */ 2450 | 2451 | /** 2452 | * Wrapped type `any`. 2453 | * @see _.chain 2454 | **/ 2455 | chain(): _Chain; 2456 | 2457 | /** 2458 | * Wrapped type `any`. 2459 | * Extracts the value of a wrapped object. 2460 | * @return Value of the wrapped object. 2461 | **/ 2462 | value(): TResult; 2463 | } 2464 | 2465 | interface _Chain { 2466 | 2467 | /* ************* 2468 | * Collections * 2469 | ************* */ 2470 | 2471 | /** 2472 | * Wrapped type `any[]`. 2473 | * @see _.each 2474 | **/ 2475 | each(iterator: _.ListIterator, context?: any): _Chain; 2476 | 2477 | /** 2478 | * @see _.each 2479 | **/ 2480 | each(iterator: _.ObjectIterator, context?: any): _Chain; 2481 | 2482 | /** 2483 | * @see _.each 2484 | **/ 2485 | forEach(iterator: _.ListIterator, context?: any): _Chain; 2486 | 2487 | /** 2488 | * @see _.each 2489 | **/ 2490 | forEach(iterator: _.ObjectIterator, context?: any): _Chain; 2491 | 2492 | /** 2493 | * Wrapped type `any[]`. 2494 | * @see _.map 2495 | **/ 2496 | map(iterator: _.ListIterator, context?: any): _ChainOfArrays; 2497 | 2498 | /** 2499 | * Wrapped type `any[]`. 2500 | * @see _.map 2501 | **/ 2502 | map(iterator: _.ListIterator, context?: any): _Chain; 2503 | 2504 | /** 2505 | * Wrapped type `any[]`. 2506 | * @see _.map 2507 | **/ 2508 | map(iterator: _.ObjectIterator, context?: any): _ChainOfArrays; 2509 | 2510 | /** 2511 | * Wrapped type `any[]`. 2512 | * @see _.map 2513 | **/ 2514 | map(iterator: _.ObjectIterator, context?: any): _Chain; 2515 | 2516 | /** 2517 | * @see _.map 2518 | **/ 2519 | collect(iterator: _.ListIterator, context?: any): _Chain; 2520 | 2521 | /** 2522 | * @see _.map 2523 | **/ 2524 | collect(iterator: _.ObjectIterator, context?: any): _Chain; 2525 | 2526 | /** 2527 | * Wrapped type `any[]`. 2528 | * @see _.reduce 2529 | **/ 2530 | reduce(iterator: _.MemoIterator, memo?: TResult, context?: any): _ChainSingle; 2531 | 2532 | /** 2533 | * @see _.reduce 2534 | **/ 2535 | inject(iterator: _.MemoIterator, memo?: TResult, context?: any): _ChainSingle; 2536 | 2537 | /** 2538 | * @see _.reduce 2539 | **/ 2540 | foldl(iterator: _.MemoIterator, memo?: TResult, context?: any): _ChainSingle; 2541 | 2542 | /** 2543 | * Wrapped type `any[]`. 2544 | * @see _.reduceRight 2545 | **/ 2546 | reduceRight(iterator: _.MemoIterator, memo?: TResult, context?: any): _ChainSingle; 2547 | 2548 | /** 2549 | * @see _.reduceRight 2550 | **/ 2551 | foldr(iterator: _.MemoIterator, memo?: TResult, context?: any): _ChainSingle; 2552 | 2553 | /** 2554 | * Wrapped type `any[]`. 2555 | * @see _.find 2556 | **/ 2557 | find(iterator: _.ListIterator, context?: any): _ChainSingle; 2558 | 2559 | /** 2560 | * @see _.find 2561 | **/ 2562 | detect(iterator: _.ListIterator, context?: any): _Chain; 2563 | 2564 | /** 2565 | * Wrapped type `any[]`. 2566 | * @see _.filter 2567 | **/ 2568 | filter(iterator: _.ListIterator, context?: any): _Chain; 2569 | 2570 | /** 2571 | * @see _.filter 2572 | **/ 2573 | select(iterator: _.ListIterator, context?: any): _Chain; 2574 | 2575 | /** 2576 | * Wrapped type `any[]`. 2577 | * @see _.where 2578 | **/ 2579 | where(properties: U): _Chain; 2580 | 2581 | /** 2582 | * Wrapped type `any[]`. 2583 | * @see _.findWhere 2584 | **/ 2585 | findWhere(properties: U): _ChainSingle; 2586 | 2587 | /** 2588 | * Wrapped type `any[]`. 2589 | * @see _.reject 2590 | **/ 2591 | reject(iterator: _.ListIterator, context?: any): _Chain; 2592 | 2593 | /** 2594 | * Wrapped type `any[]`. 2595 | * @see _.all 2596 | **/ 2597 | all(iterator?: _.ListIterator, context?: any): _Chain; 2598 | 2599 | /** 2600 | * @see _.all 2601 | **/ 2602 | every(iterator?: _.ListIterator, context?: any): _Chain; 2603 | 2604 | /** 2605 | * Wrapped type `any[]`. 2606 | * @see _.any 2607 | **/ 2608 | any(iterator?: _.ListIterator, context?: any): _Chain; 2609 | 2610 | /** 2611 | * @see _.any 2612 | **/ 2613 | some(iterator?: _.ListIterator, context?: any): _Chain; 2614 | 2615 | /** 2616 | * Wrapped type `any[]`. 2617 | * @see _.contains 2618 | **/ 2619 | contains(value: T): _Chain; 2620 | 2621 | /** 2622 | * Alias for 'contains'. 2623 | * @see contains 2624 | **/ 2625 | include(value: T): _Chain; 2626 | 2627 | /** 2628 | * Wrapped type `any[]`. 2629 | * @see _.invoke 2630 | **/ 2631 | invoke(methodName: string, ...arguments: any[]): _Chain; 2632 | 2633 | /** 2634 | * Wrapped type `any[]`. 2635 | * @see _.pluck 2636 | **/ 2637 | pluck(propertyName: string): _Chain; 2638 | 2639 | /** 2640 | * Wrapped type `number[]`. 2641 | * @see _.max 2642 | **/ 2643 | max(): _ChainSingle; 2644 | 2645 | /** 2646 | * Wrapped type `any[]`. 2647 | * @see _.max 2648 | **/ 2649 | max(iterator: _.ListIterator, context?: any): _ChainSingle; 2650 | 2651 | /** 2652 | * Wrapped type `any[]`. 2653 | * @see _.max 2654 | **/ 2655 | max(iterator?: _.ListIterator, context?: any): _ChainSingle; 2656 | 2657 | /** 2658 | * Wrapped type `number[]`. 2659 | * @see _.min 2660 | **/ 2661 | min(): _ChainSingle; 2662 | 2663 | /** 2664 | * Wrapped type `any[]`. 2665 | * @see _.min 2666 | **/ 2667 | min(iterator: _.ListIterator, context?: any): _ChainSingle; 2668 | 2669 | /** 2670 | * Wrapped type `any[]`. 2671 | * @see _.min 2672 | **/ 2673 | min(iterator?: _.ListIterator, context?: any): _ChainSingle; 2674 | 2675 | /** 2676 | * Wrapped type `any[]`. 2677 | * @see _.sortBy 2678 | **/ 2679 | sortBy(iterator?: _.ListIterator, context?: any): _Chain; 2680 | 2681 | /** 2682 | * Wrapped type `any[]`. 2683 | * @see _.sortBy 2684 | **/ 2685 | sortBy(iterator: string, context?: any): _Chain; 2686 | 2687 | /** 2688 | * Wrapped type `any[]`. 2689 | * @see _.groupBy 2690 | **/ 2691 | groupBy(iterator?: _.ListIterator, context?: any): _ChainOfArrays; 2692 | 2693 | /** 2694 | * Wrapped type `any[]`. 2695 | * @see _.groupBy 2696 | **/ 2697 | groupBy(iterator: string, context?: any): _ChainOfArrays; 2698 | 2699 | /** 2700 | * Wrapped type `any[]`. 2701 | * @see _.indexBy 2702 | **/ 2703 | indexBy(iterator: _.ListIterator, context?: any): _Chain; 2704 | 2705 | /** 2706 | * Wrapped type `any[]`. 2707 | * @see _.indexBy 2708 | **/ 2709 | indexBy(iterator: string, context?: any): _Chain; 2710 | 2711 | /** 2712 | * Wrapped type `any[]`. 2713 | * @see _.countBy 2714 | **/ 2715 | countBy(iterator?: _.ListIterator, context?: any): _Chain; 2716 | 2717 | /** 2718 | * Wrapped type `any[]`. 2719 | * @see _.countBy 2720 | **/ 2721 | countBy(iterator: string, context?: any): _Chain; 2722 | 2723 | /** 2724 | * Wrapped type `any[]`. 2725 | * @see _.shuffle 2726 | **/ 2727 | shuffle(): _Chain; 2728 | 2729 | /** 2730 | * Wrapped type `any[]`. 2731 | * @see _.sample 2732 | **/ 2733 | sample(n: number): _Chain; 2734 | 2735 | /** 2736 | * @see _.sample 2737 | **/ 2738 | sample(): _Chain; 2739 | 2740 | /** 2741 | * Wrapped type `any`. 2742 | * @see _.toArray 2743 | **/ 2744 | toArray(): _Chain; 2745 | 2746 | /** 2747 | * Wrapped type `any`. 2748 | * @see _.size 2749 | **/ 2750 | size(): _Chain; 2751 | 2752 | /********* 2753 | * Arrays * 2754 | **********/ 2755 | 2756 | /** 2757 | * Wrapped type `any[]`. 2758 | * @see _.first 2759 | **/ 2760 | first(): _ChainSingle; 2761 | 2762 | /** 2763 | * Wrapped type `any[]`. 2764 | * @see _.first 2765 | **/ 2766 | first(n: number): _Chain; 2767 | 2768 | /** 2769 | * @see _.first 2770 | **/ 2771 | head(): _Chain; 2772 | 2773 | /** 2774 | * @see _.first 2775 | **/ 2776 | head(n: number): _Chain; 2777 | 2778 | /** 2779 | * @see _.first 2780 | **/ 2781 | take(): _Chain; 2782 | 2783 | /** 2784 | * @see _.first 2785 | **/ 2786 | take(n: number): _Chain; 2787 | 2788 | /** 2789 | * Wrapped type `any[]`. 2790 | * @see _.initial 2791 | **/ 2792 | initial(n?: number): _Chain; 2793 | 2794 | /** 2795 | * Wrapped type `any[]`. 2796 | * @see _.last 2797 | **/ 2798 | last(): _ChainSingle; 2799 | 2800 | /** 2801 | * Wrapped type `any[]`. 2802 | * @see _.last 2803 | **/ 2804 | last(n: number): _Chain; 2805 | 2806 | /** 2807 | * Wrapped type `any[]`. 2808 | * @see _.rest 2809 | **/ 2810 | rest(n?: number): _Chain; 2811 | 2812 | /** 2813 | * @see _.rest 2814 | **/ 2815 | tail(n?: number): _Chain; 2816 | 2817 | /** 2818 | * @see _.rest 2819 | **/ 2820 | drop(n?: number): _Chain; 2821 | 2822 | /** 2823 | * Wrapped type `any[]`. 2824 | * @see _.compact 2825 | **/ 2826 | compact(): _Chain; 2827 | 2828 | /** 2829 | * Wrapped type `any`. 2830 | * @see _.flatten 2831 | **/ 2832 | flatten(shallow?: boolean): _Chain; 2833 | 2834 | /** 2835 | * Wrapped type `any[]`. 2836 | * @see _.without 2837 | **/ 2838 | without(...values: T[]): _Chain; 2839 | 2840 | /** 2841 | * Wrapped type `any[]`. 2842 | * @see _.partition 2843 | **/ 2844 | partition(iterator: _.ListIterator, context?: any): _Chain; 2845 | 2846 | /** 2847 | * Wrapped type `any[][]`. 2848 | * @see _.union 2849 | **/ 2850 | union(...arrays: _.List[]): _Chain; 2851 | 2852 | /** 2853 | * Wrapped type `any[][]`. 2854 | * @see _.intersection 2855 | **/ 2856 | intersection(...arrays: _.List[]): _Chain; 2857 | 2858 | /** 2859 | * Wrapped type `any[]`. 2860 | * @see _.difference 2861 | **/ 2862 | difference(...others: _.List[]): _Chain; 2863 | 2864 | /** 2865 | * Wrapped type `any[]`. 2866 | * @see _.uniq 2867 | **/ 2868 | uniq(isSorted?: boolean, iterator?: _.ListIterator): _Chain; 2869 | 2870 | /** 2871 | * Wrapped type `any[]`. 2872 | * @see _.uniq 2873 | **/ 2874 | uniq(iterator?: _.ListIterator, context?: any): _Chain; 2875 | 2876 | /** 2877 | * @see _.uniq 2878 | **/ 2879 | unique(isSorted?: boolean, iterator?: _.ListIterator): _Chain; 2880 | 2881 | /** 2882 | * @see _.uniq 2883 | **/ 2884 | unique(iterator?: _.ListIterator, context?: any): _Chain; 2885 | 2886 | /** 2887 | * Wrapped type `any[][]`. 2888 | * @see _.zip 2889 | **/ 2890 | zip(...arrays: any[][]): _Chain; 2891 | 2892 | /** 2893 | * Wrapped type `any[][]`. 2894 | * @see _.object 2895 | **/ 2896 | object(...keyValuePairs: any[][]): _Chain; 2897 | 2898 | /** 2899 | * @see _.object 2900 | **/ 2901 | object(values?: any): _Chain; 2902 | 2903 | /** 2904 | * Wrapped type `any[]`. 2905 | * @see _.indexOf 2906 | **/ 2907 | indexOf(value: T, isSorted?: boolean): _ChainSingle; 2908 | 2909 | /** 2910 | * @see _.indexOf 2911 | **/ 2912 | indexOf(value: T, startFrom: number): _ChainSingle; 2913 | 2914 | /** 2915 | * Wrapped type `any[]`. 2916 | * @see _.lastIndexOf 2917 | **/ 2918 | lastIndexOf(value: T, from?: number): _ChainSingle; 2919 | 2920 | /** 2921 | * Wrapped type `any[]`. 2922 | * @see _.sortedIndex 2923 | **/ 2924 | sortedIndex(value: T, iterator?: (x: T) => any, context?: any): _Chain; 2925 | 2926 | /** 2927 | * Wrapped type `number`. 2928 | * @see _.range 2929 | **/ 2930 | range(stop: number, step?: number): _Chain; 2931 | 2932 | /** 2933 | * Wrapped type `number`. 2934 | * @see _.range 2935 | **/ 2936 | range(): _Chain; 2937 | 2938 | /* *********** 2939 | * Functions * 2940 | ************ */ 2941 | 2942 | /** 2943 | * Wrapped type `Function`. 2944 | * @see _.bind 2945 | **/ 2946 | bind(object: any, ...arguments: any[]): _Chain; 2947 | 2948 | /** 2949 | * Wrapped type `object`. 2950 | * @see _.bindAll 2951 | **/ 2952 | bindAll(...methodNames: string[]): _Chain; 2953 | 2954 | /** 2955 | * Wrapped type `Function`. 2956 | * @see _.partial 2957 | **/ 2958 | partial(...arguments: any[]): _Chain; 2959 | 2960 | /** 2961 | * Wrapped type `Function`. 2962 | * @see _.memoize 2963 | **/ 2964 | memoize(hashFn?: (n: any) => string): _Chain; 2965 | 2966 | /** 2967 | * Wrapped type `Function`. 2968 | * @see _.defer 2969 | **/ 2970 | defer(...arguments: any[]): _Chain; 2971 | 2972 | /** 2973 | * Wrapped type `Function`. 2974 | * @see _.delay 2975 | **/ 2976 | delay(wait: number, ...arguments: any[]): _Chain; 2977 | 2978 | /** 2979 | * @see _.delay 2980 | **/ 2981 | delay(...arguments: any[]): _Chain; 2982 | 2983 | /** 2984 | * Wrapped type `Function`. 2985 | * @see _.throttle 2986 | **/ 2987 | throttle(wait: number, options?: _.ThrottleSettings): _Chain; 2988 | 2989 | /** 2990 | * Wrapped type `Function`. 2991 | * @see _.debounce 2992 | **/ 2993 | debounce(wait: number, immediate?: boolean): _Chain; 2994 | 2995 | /** 2996 | * Wrapped type `Function`. 2997 | * @see _.once 2998 | **/ 2999 | once(): _Chain; 3000 | 3001 | /** 3002 | * Wrapped type `number`. 3003 | * @see _.after 3004 | **/ 3005 | after(func: Function): _Chain; 3006 | 3007 | /** 3008 | * Wrapped type `number`. 3009 | * @see _.before 3010 | **/ 3011 | before(fn: Function): _Chain; 3012 | 3013 | /** 3014 | * Wrapped type `Function`. 3015 | * @see _.wrap 3016 | **/ 3017 | wrap(wrapper: Function): () => _Chain; 3018 | 3019 | /** 3020 | * Wrapped type `Function`. 3021 | * @see _.negate 3022 | **/ 3023 | negate(): _Chain; 3024 | 3025 | /** 3026 | * Wrapped type `Function[]`. 3027 | * @see _.compose 3028 | **/ 3029 | compose(...functions: Function[]): _Chain; 3030 | 3031 | /********* * 3032 | * Objects * 3033 | ********** */ 3034 | 3035 | /** 3036 | * Wrapped type `object`. 3037 | * @see _.keys 3038 | **/ 3039 | keys(): _Chain; 3040 | 3041 | /** 3042 | * Wrapped type `object`. 3043 | * @see _.values 3044 | **/ 3045 | values(): _Chain; 3046 | 3047 | /** 3048 | * Wrapped type `object`. 3049 | * @see _.pairs 3050 | **/ 3051 | pairs(): _Chain; 3052 | 3053 | /** 3054 | * Wrapped type `object`. 3055 | * @see _.invert 3056 | **/ 3057 | invert(): _Chain; 3058 | 3059 | /** 3060 | * Wrapped type `object`. 3061 | * @see _.functions 3062 | **/ 3063 | functions(): _Chain; 3064 | 3065 | /** 3066 | * @see _.functions 3067 | **/ 3068 | methods(): _Chain; 3069 | 3070 | /** 3071 | * Wrapped type `object`. 3072 | * @see _.extend 3073 | **/ 3074 | extend(...sources: any[]): _Chain; 3075 | 3076 | /** 3077 | * Wrapped type `object`. 3078 | * @see _.pick 3079 | **/ 3080 | pick(...keys: any[]): _Chain; 3081 | pick(keys: any[]): _Chain; 3082 | pick(fn: (value: any, key: any, object: any) => any): _Chain; 3083 | 3084 | /** 3085 | * Wrapped type `object`. 3086 | * @see _.omit 3087 | **/ 3088 | omit(...keys: string[]): _Chain; 3089 | omit(keys: string[]): _Chain; 3090 | omit(iteratee: Function): _Chain; 3091 | 3092 | /** 3093 | * Wrapped type `object`. 3094 | * @see _.defaults 3095 | **/ 3096 | defaults(...defaults: any[]): _Chain; 3097 | 3098 | /** 3099 | * Wrapped type `any[]`. 3100 | * @see _.clone 3101 | **/ 3102 | clone(): _Chain; 3103 | 3104 | /** 3105 | * Wrapped type `object`. 3106 | * @see _.tap 3107 | **/ 3108 | tap(interceptor: (...as: any[]) => any): _Chain; 3109 | 3110 | /** 3111 | * Wrapped type `object`. 3112 | * @see _.has 3113 | **/ 3114 | has(key: string): _Chain; 3115 | 3116 | /** 3117 | * Wrapped type `any[]`. 3118 | * @see _.matches 3119 | **/ 3120 | matches(): _Chain; 3121 | 3122 | /** 3123 | * Wrapped type `string`. 3124 | * @see _.property 3125 | **/ 3126 | property(): _Chain; 3127 | 3128 | /** 3129 | * Wrapped type `object`. 3130 | * @see _.isEqual 3131 | **/ 3132 | isEqual(other: any): _Chain; 3133 | 3134 | /** 3135 | * Wrapped type `object`. 3136 | * @see _.isEmpty 3137 | **/ 3138 | isEmpty(): _Chain; 3139 | 3140 | /** 3141 | * Wrapped type `object`. 3142 | * @see _.isElement 3143 | **/ 3144 | isElement(): _Chain; 3145 | 3146 | /** 3147 | * Wrapped type `object`. 3148 | * @see _.isArray 3149 | **/ 3150 | isArray(): _Chain; 3151 | 3152 | /** 3153 | * Wrapped type `object`. 3154 | * @see _.isObject 3155 | **/ 3156 | isObject(): _Chain; 3157 | 3158 | /** 3159 | * Wrapped type `object`. 3160 | * @see _.isArguments 3161 | **/ 3162 | isArguments(): _Chain; 3163 | 3164 | /** 3165 | * Wrapped type `object`. 3166 | * @see _.isFunction 3167 | **/ 3168 | isFunction(): _Chain; 3169 | 3170 | /** 3171 | * Wrapped type `object`. 3172 | * @see _.isString 3173 | **/ 3174 | isString(): _Chain; 3175 | 3176 | /** 3177 | * Wrapped type `object`. 3178 | * @see _.isNumber 3179 | **/ 3180 | isNumber(): _Chain; 3181 | 3182 | /** 3183 | * Wrapped type `object`. 3184 | * @see _.isFinite 3185 | **/ 3186 | isFinite(): _Chain; 3187 | 3188 | /** 3189 | * Wrapped type `object`. 3190 | * @see _.isBoolean 3191 | **/ 3192 | isBoolean(): _Chain; 3193 | 3194 | /** 3195 | * Wrapped type `object`. 3196 | * @see _.isDate 3197 | **/ 3198 | isDate(): _Chain; 3199 | 3200 | /** 3201 | * Wrapped type `object`. 3202 | * @see _.isRegExp 3203 | **/ 3204 | isRegExp(): _Chain; 3205 | 3206 | /** 3207 | * Wrapped type `object`. 3208 | * @see _.isNaN 3209 | **/ 3210 | isNaN(): _Chain; 3211 | 3212 | /** 3213 | * Wrapped type `object`. 3214 | * @see _.isNull 3215 | **/ 3216 | isNull(): _Chain; 3217 | 3218 | /** 3219 | * Wrapped type `object`. 3220 | * @see _.isUndefined 3221 | **/ 3222 | isUndefined(): _Chain; 3223 | 3224 | /********* * 3225 | * Utility * 3226 | ********** */ 3227 | 3228 | /** 3229 | * Wrapped type `any`. 3230 | * @see _.identity 3231 | **/ 3232 | identity(): _Chain; 3233 | 3234 | /** 3235 | * Wrapped type `any`. 3236 | * @see _.constant 3237 | **/ 3238 | constant(): _Chain; 3239 | 3240 | /** 3241 | * Wrapped type `any`. 3242 | * @see _.noop 3243 | **/ 3244 | noop(): _Chain; 3245 | 3246 | /** 3247 | * Wrapped type `number`. 3248 | * @see _.times 3249 | **/ 3250 | times(iterator: (n: number) => TResult, context?: any): _Chain; 3251 | 3252 | /** 3253 | * Wrapped type `number`. 3254 | * @see _.random 3255 | **/ 3256 | random(): _Chain; 3257 | /** 3258 | * Wrapped type `number`. 3259 | * @see _.random 3260 | **/ 3261 | random(max: number): _Chain; 3262 | 3263 | /** 3264 | * Wrapped type `object`. 3265 | * @see _.mixin 3266 | **/ 3267 | mixin(): _Chain; 3268 | 3269 | /** 3270 | * Wrapped type `string|Function|Object`. 3271 | * @see _.iteratee 3272 | **/ 3273 | iteratee(context?: any, argCount?: number): _Chain; 3274 | 3275 | /** 3276 | * Wrapped type `string`. 3277 | * @see _.uniqueId 3278 | **/ 3279 | uniqueId(): _Chain; 3280 | 3281 | /** 3282 | * Wrapped type `string`. 3283 | * @see _.escape 3284 | **/ 3285 | escape(): _Chain; 3286 | 3287 | /** 3288 | * Wrapped type `string`. 3289 | * @see _.unescape 3290 | **/ 3291 | unescape(): _Chain; 3292 | 3293 | /** 3294 | * Wrapped type `object`. 3295 | * @see _.result 3296 | **/ 3297 | result(property: string): _Chain; 3298 | 3299 | /** 3300 | * Wrapped type `string`. 3301 | * @see _.template 3302 | **/ 3303 | template(settings?: _.TemplateSettings): (...data: any[]) => _Chain; 3304 | 3305 | /************* * 3306 | * Array proxy * 3307 | ************** */ 3308 | 3309 | /** 3310 | * Returns a new array comprised of the array on which it is called 3311 | * joined with the array(s) and/or value(s) provided as arguments. 3312 | * @param arr Arrays and/or values to concatenate into a new array. See the discussion below for details. 3313 | * @return A new array comprised of the array on which it is called 3314 | **/ 3315 | concat(...arr: Array): _Chain; 3316 | 3317 | /** 3318 | * Join all elements of an array into a string. 3319 | * @param separator Optional. Specifies a string to separate each element of the array. The separator is converted to a string if necessary. If omitted, the array elements are separated with a comma. 3320 | * @return The string conversions of all array elements joined into one string. 3321 | **/ 3322 | join(separator?: any): _ChainSingle; 3323 | 3324 | /** 3325 | * Removes the last element from an array and returns that element. 3326 | * @return Returns the popped element. 3327 | **/ 3328 | pop(): _ChainSingle; 3329 | 3330 | /** 3331 | * Adds one or more elements to the end of an array and returns the new length of the array. 3332 | * @param item The elements to add to the end of the array. 3333 | * @return The array with the element added to the end. 3334 | **/ 3335 | push(...item: Array): _Chain; 3336 | 3337 | /** 3338 | * Reverses an array in place. The first array element becomes the last and the last becomes the first. 3339 | * @return The reversed array. 3340 | **/ 3341 | reverse(): _Chain; 3342 | 3343 | /** 3344 | * Removes the first element from an array and returns that element. This method changes the length of the array. 3345 | * @return The shifted element. 3346 | **/ 3347 | shift(): _ChainSingle; 3348 | 3349 | /** 3350 | * Returns a shallow copy of a portion of an array into a new array object. 3351 | * @param start Zero-based index at which to begin extraction. 3352 | * @param end Optional. Zero-based index at which to end extraction. slice extracts up to but not including end. 3353 | * @return A shallow copy of a portion of an array into a new array object. 3354 | **/ 3355 | slice(start: number, end?: number): _Chain; 3356 | 3357 | /** 3358 | * Sorts the elements of an array in place and returns the array. The sort is not necessarily stable. The default sort order is according to string Unicode code points. 3359 | * @param compareFn Optional. Specifies a function that defines the sort order. If omitted, the array is sorted according to each character's Unicode code point value, according to the string conversion of each element. 3360 | * @return The sorted array. 3361 | **/ 3362 | sort(compareFn: (a: T, b: T) => boolean): _Chain; 3363 | 3364 | /** 3365 | * Changes the content of an array by removing existing elements and/or adding new elements. 3366 | * @param index Index at which to start changing the array. If greater than the length of the array, actual starting index will be set to the length of the array. If negative, will begin that many elements from the end. 3367 | * @param quantity An integer indicating the number of old array elements to remove. If deleteCount is 0, no elements are removed. In this case, you should specify at least one new element. If deleteCount is greater than the number of elements left in the array starting at index, then all of the elements through the end of the array will be deleted. 3368 | * @param items The element to add to the array. If you don't specify any elements, splice will only remove elements from the array. 3369 | * @return An array containing the deleted elements. If only one element is removed, an array of one element is returned. If no elements are removed, an empty array is returned. 3370 | **/ 3371 | splice(index: number, quantity: number, ...items: Array): _Chain; 3372 | 3373 | /** 3374 | * A string representing the specified array and its elements. 3375 | * @return A string representing the specified array and its elements. 3376 | **/ 3377 | toString(): _ChainSingle; 3378 | 3379 | /** 3380 | * Adds one or more elements to the beginning of an array and returns the new length of the array. 3381 | * @param items The elements to add to the front of the array. 3382 | * @return The array with the element added to the beginning. 3383 | **/ 3384 | unshift(...items: Array): _Chain; 3385 | 3386 | /********** * 3387 | * Chaining * 3388 | *********** */ 3389 | 3390 | /** 3391 | * Wrapped type `any`. 3392 | * @see _.chain 3393 | **/ 3394 | chain(): _Chain; 3395 | 3396 | /** 3397 | * Wrapped type `any`. 3398 | * @see _.value 3399 | **/ 3400 | value(): T[]; 3401 | } 3402 | interface _ChainSingle { 3403 | value(): T; 3404 | } 3405 | interface _ChainOfArrays extends _Chain { 3406 | flatten(): _Chain; 3407 | } 3408 | 3409 | declare var _: UnderscoreStatic; 3410 | 3411 | declare module "underscore" { 3412 | export = _; 3413 | } 3414 | -------------------------------------------------------------------------------- /typings/vscode-typings.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | --------------------------------------------------------------------------------