This commit is contained in:
Sean McBreen 2015-10-02 17:31:49 -07:00
Родитель 2d03270b19
Коммит 880546eb7c
14 изменённых файлов: 4369 добавлений и 0 удалений

2
.gitignore поставляемый Normal file
Просмотреть файл

@ -0,0 +1,2 @@
out
node_modules

16
.vscode/launch.json поставляемый Normal file
Просмотреть файл

@ -0,0 +1,16 @@
// A launch configuration that compiles the extension and then opens it inside a new window
{
"version": "0.1.0",
"configurations": [
{
"name": "Launch Extension",
"type": "extensionHost",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceRoot}" ],
"stopOnEntry": false,
"sourceMaps": true,
"outDir": "out",
"preLaunchTask": "npm"
}
]
}

7
.vscode/settings.json поставляемый Normal file
Просмотреть файл

@ -0,0 +1,7 @@
// Place your settings in this file to overwrite default and user settings.
{
"spellMD.enable": true,
"files.exclude": {
"out": false // set this to true to hide the "out" folder with the compiled JS files
}
}

30
.vscode/tasks.json поставляемый Normal file
Просмотреть файл

@ -0,0 +1,30 @@
// Available variables which can be used inside of strings.
// ${workspaceRoot}: the root folder of the team
// ${file}: the current opened file
// ${fileBasename}: the current opened file's basename
// ${fileDirname}: the current opened file's dirname
// ${fileExtname}: the current opened file's extension
// ${cwd}: the current working directory of the spawned process
// A task runner that calls a custom npm script that compiles the extension.
{
"version": "0.1.0",
// we want to run npm
"command": "npm",
// the command is a shell script
"isShellCommand": true,
// show the output window only if unrecognized errors occur.
"showOutput": "silent",
// we run the custom script "compile" as defined in package.json
"args": ["run", "compile"],
// The tsc compiler is started in watching mode
"isWatching": true,
// use the standard tsc in watch mode problem matcher to find compile problems in the output.
"problemMatcher": "$tsc-watch"
}

6
.vscodeignore Normal file
Просмотреть файл

@ -0,0 +1,6 @@
.vscode/**
typings/**
**/*.ts
.gitignore
tsconfig.json
vsc-extension-quickstart.md

52
README.md Normal file
Просмотреть файл

@ -0,0 +1,52 @@
# README
This extension does the following:
## WordCount File Watcher
Whenever a `markdown` file is loaded a status bar message is added which includes the current word count - this live updates as you type and move from file to file:
![Status](images/StatusWordCount.gif)
### Issues: Word Count
the events for opening and closing a file don't seam to fire predictably:
Repro:
1. run extension
2. open a folder w/ moced filed
3. open a `.md` file status bar _may_ activate
4. once activzated navigate to another file e.g. `.js`
5. status bar stay stay active
6. navigate to another `.md` status bar will probably activate but may have a stale count
## Keybinding 'Alt+T' - Test Tools
Also available as `command`.
Hit `Alt+T` to get some text replacement tools e.g.
* toUpper
* toLower
* Reverse
* HTML Encode
* ..
![Tools](images/commands.gif)
Will replace all selections in the current editor.
### Issues: Ugly Code
Lots of copy and paste can abstract [my] common code.
### Issues: Encode HTML
This function will replace the selection(s) with more text than they had orriginally e.g.
* `hello <div> world`
* Results in `hello &gt;div&lt; world`
In the code I attempt to handle this with some simple re-writing of the selection range from the replacement `txt.length`. However the resulting selection is much longer.
Repro:
1. Open a doc
2. select some text w/ html in it
3. `Alt+T' select Encode HTML
4. Resulting selection will be to long and the status bar indication of 'selected' will be incorrect
I see some debug style output in the console for sections as well.

220
extension.ts Normal file
Просмотреть файл

@ -0,0 +1,220 @@
import * as vscode from 'vscode';
import window = vscode.window;
import workspace = vscode.workspace;
import EditorOptions = vscode.TextEditorOptions;
import QuickPickItem = vscode.QuickPickItem;
import QuickPickOptions = vscode.QuickPickOptions;
import Document = vscode.TextDocument;
import Position = vscode.Position;
import Range = vscode.Range;
import InputBoxOptions = vscode.InputBoxOptions;
import us = require('underscore.string');
export function activate() {
console.log('Congratulations, your extension "TextTools" is now active!');
let wordCountStatus = new WordCountStatus();
vscode.commands.registerCommand('extension.textFunctions', textFunctions);
}
// Word Count /////////////////////////////////////
class WordCountStatus {
constructor() {
window.onDidChangeTextEditorSelection((textEditor) => {
if (!textEditor) {
// No more open editors
return;
}
let doc = textEditor.textEditor.getTextDocument();
// Only update status if an MD file
if (doc.getLanguageId() === "markdown") {
window.setStatusBarMessage("Word Count [" + calcWordCount(doc.getText()) + "]");
} else {
window.setStatusBarMessage("");
}
});
}
}
function calcWordCount(text): number {
text = text.replace(/(< ([^>]+)<)/g, '').replace(/\s+/g, ' ');
text = text.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
return text.split(" ").length;
}
// Selections test /////////////////////////////////////
function workWithSelections() {
var e = window.getActiveTextEditor();
var d = e.getTextDocument();
// Subset of text
var start = new Position(1, 1);
var end = new Position(10, 3);
var range = new Range(start, end);
console.log("Range: " + d.getTextInRange(range));
// All text
console.log("All: " + d.getText());
}
// String Functions Helper//////////////////////////////
function toUpper(e: vscode.TextEditor, d: vscode.TextDocument, sel: vscode.Selection[]) {
// itterate through the elections and convert all text to Upper
for (var x = 0; x < sel.length; x++) {
e.edit(function(edit) {
let txt: string = d.getTextInRange(new Range(sel[x].start, sel[x].end));
edit.replace(sel[x], txt.toUpperCase());
});
e.setSelections(sel)
}
}
function toLower(e: vscode.TextEditor, d: vscode.TextDocument, sel: vscode.Selection[]) {
// itterate through the elections and convert all text to Upper
for (var x = 0; x < sel.length; x++) {
e.edit(function(edit) {
let txt: string = d.getTextInRange(new Range(sel[x].start, sel[x].end));
edit.replace(sel[x], txt.toLowerCase());
});
e.setSelections(sel)
}
}
function swapCase(e: vscode.TextEditor, d: vscode.TextDocument, sel: vscode.Selection[]) {
// itterate through the elections and convert all text to Upper
for (var x = 0; x < sel.length; x++) {
e.edit(function(edit) {
let txt: string = d.getTextInRange(new Range(sel[x].start, sel[x].end));
edit.replace(sel[x], us.swapCase(txt));
});
e.setSelections(sel)
}
}
function cleanString(e: vscode.TextEditor, d: vscode.TextDocument, sel: vscode.Selection[]) {
// itterate through the elections and convert all text to Upper
for (var x = 0; x < sel.length; x++) {
e.edit(function(edit) {
let txt: string = d.getTextInRange(new Range(sel[x].start, sel[x].end));
edit.replace(sel[x], us.clean(txt));
});
e.setSelections(sel)
}
}
function titleize(e: vscode.TextEditor, d: vscode.TextDocument, sel: vscode.Selection[]) {
// itterate through the elections and convert all text to Upper
for (var x = 0; x < sel.length; x++) {
e.edit(function(edit) {
let txt: string = d.getTextInRange(new Range(sel[x].start, sel[x].end));
edit.replace(sel[x], us.titleize(txt));
});
e.setSelections(sel)
}
}
function escapeHTML(e: vscode.TextEditor, d: vscode.TextDocument, sel: vscode.Selection[]) {
// itterate through the selections
for (var x = 0; x < sel.length; x++) {
e.edit(function(edit) {
// process the selection and replace in editor
var txt: string = us.escapeHTML(d.getTextInRange(new Range(sel[x].start, sel[x].end)));
edit.replace(sel[x], txt);
// fix the selection as it could now be longer or shorter
let startPos: Position = new Position(sel[x].start.line, sel[x].start.column);
let endPos: Position = new Position(sel[x].end.line,sel[x].start.column + txt.length);
let replaceRange : Range = new Range(startPos, endPos);
e.setSelection(replaceRange);
});
}
}
function unescapeHTML(e: vscode.TextEditor, d: vscode.TextDocument, sel: vscode.Selection[]) {
// itterate through the elections and convert all text to Upper
for (var x = 0; x < sel.length; x++) {
e.edit(function(edit) {
let txt: string = d.getTextInRange(new Range(sel[x].start, sel[x].end));
edit.replace(sel[x], us.unescapeHTML(txt));
});
e.setSelections(sel)
}
}
function reverse(e: vscode.TextEditor, d: vscode.TextDocument, sel: vscode.Selection[]) {
// itterate through the elections and convert all text to Upper
for (var x = 0; x < sel.length; x++) {
e.edit(function(edit) {
edit.replace(sel[x], us.reverse(d.getTextInRange(new Range(sel[x].start, sel[x].end))));
});
e.setSelections(sel)
}
}
// Text Functions /////////////////////////////////////
function textFunctions() {
var opts: QuickPickOptions = { matchOnDescription: true, placeHolder: "What do you want to do to the selection(s)?" };
var items: QuickPickItem[] = [];
items.push({ label: "toUpper", description: "Convert [aBc] to [ABC]" });
items.push({ label: "toLower", description: "Convert [aBc] to [abc]" });
items.push({ label: "swapCase", description: "Convert [aBc] to [AbC]" });
items.push({ label: "Titleize", description: "Convert [hello world] to [Hello World]" });
items.push({ label: "Clean String", description: "Convert [hello world] to [hello world]" });
items.push({ label: "Reverse", description: "Convert [hello world] to [world hello]" });
items.push({ label: "Escape HTML", description: "Convert [<div>hello] to [&lt;div&gt;hello]" });
items.push({ label: "UnEscape HTML", description: "Convert [&lt;div&gt;hello] to [<div>hello]" });
window.showQuickPick(items).then((selection) => {
let e = window.getActiveTextEditor();
let d = e.getTextDocument();
let sel = e.getSelections();
switch (selection.label) {
case "toUpper":
toUpper(e, d, sel);
break;
case "toLower":
toLower(e, d, sel);
break;
case "swapCase":
swapCase(e, d, sel);
break;
case "Titleize":
titleize(e, d, sel);
break;
case "Clean String":
cleanString(e, d, sel);
break;
case "Reverse":
reverse(e, d, sel);
break;
case "Escape HTML":
escapeHTML(e, d, sel);
break;
case "UnEscape HTML":
unescapeHTML(e, d, sel);
break;
default:
console.log("hum this should not have happend - no selction")
break;
}
});
}

Двоичные данные
images/Commands.gif Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 287 KiB

Двоичные данные
images/StatusWordCount.gif Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 299 KiB

37
package.json Normal file
Просмотреть файл

@ -0,0 +1,37 @@
{
"name": "30-Command",
"version": "0.0.1",
"publisher": "Sean",
"activationEvents": [
"onLanguage:markdown"
],
"engines": {
"vscode": ">=0.9.0-pre.1"
},
"main": "./out/extension",
"contributes": {
"commands": [
{
"command": "extension.textFunctions",
"title": "Text Functions",
"description": "Text Functions on selections"
}
],
"keybindings": [
{
"command": "extension.textFunctions",
"key": "Alt+T"
}
]
},
"scripts": {
"vscode:prepublish": "node ./node_modules/vscode/bin/compile",
"compile": "node ./node_modules/vscode/bin/compile -watch -p ./"
},
"dependencies": {
"underscore.string": "^3.2.2"
},
"devDependencies": {
"vscode": ">=0.9.0-pre.1"
}
}

12
tsconfig.json Normal file
Просмотреть файл

@ -0,0 +1,12 @@
{
"compilerOptions": {
"module": "commonjs",
"outDir": "out",
"noLib": true,
"sourceMap": true,
"moduleResolution": "node"
},
"exclude": [
"node_modules"
]
}

573
typings/underscore.string/underscore.string.d.ts поставляемый Normal file
Просмотреть файл

@ -0,0 +1,573 @@
// Type definitions for underscore.string
// Project: https://github.com/epeli/underscore.string
// Definitions by: Ry Racherbaumer <http://github.com/rygine>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../underscore/underscore.d.ts" />
interface UnderscoreStatic {
str: UnderscoreStringStatic;
string: UnderscoreStringStatic;
}
declare var s : UnderscoreStringStatic;
interface UnderscoreStringStatic extends UnderscoreStringStaticExports {
/**
* Tests if string contains a substring.
* ('foobar', 'ob') => true
* @param str
* @param needle
*/
include(str: string, needle: string): boolean;
/**
* Tests if string contains a substring.
* ('foobar', 'ob') => true
* @param str
* @param needle
*/
contains(str: string, needle: string): boolean;
/**
* Return reversed string.
* ('foobar') => 'raboof'
* @param str
*/
reverse(str: string): string;
}
/**
* Functions exported for mixing with underscore object.
*
* Usage:
* _.mixin(_.string.exports());
* interface UnderscoreStatic extends UnderscoreStringStaticExports { }
*/
interface UnderscoreStringStaticExports {
exports(): UnderscoreStringStaticExports;
/**
* Determine if a string is 'blank.'
* @param str
*/
isBlank(str: string): boolean;
/**
* Removes all html tags from string.
* @param str
*/
stripTags(str: string): string;
/**
* Converts first letter of the string to uppercase.
* ('foo Bar') => 'Foo Bar'
* @param str
*/
capitalize(str: string): string;
/**
* Chop a string into pieces.
* ('whitespace', 3) => ['whi','tes','pac','e']
* @param str String to chop
* @param step Size of the pieces
*/
chop(str: string, step: number): any[];
/**
* Compress some whitespaces to one.
* (' foo bar ') => 'foo bar'
* @param str
*/
clean(str: string): string;
/**
* Count occurences of a sub string.
* ('Hello world', 'l') => 3
* @param str
* @param substr
*/
count(str: string, substr: string): number;
/**
* Convert string to an array of characters.
* ('Hello') => ['H','e','l','l','o']
* @param str
*/
chars(str: string): any[];
/**
* Returns a copy of the string in which all the case-based characters have had their case swapped.
* ('hELLO') => 'Hello'
* @param str
*/
swapCase(str: string): string;
/**
* Converts HTML special characters to their entity equivalents.
* ('<div>Blah blah blah</div>') => '&lt;div&gt;Blah blah blah&lt;/div&gt;'
* @param str
*/
escapeHTML(str: string): string;
/**
* Converts entity characters to HTML equivalents.
* ('&lt;div&gt;Blah blah blah&lt;/div&gt;') => '<div>Blah blah blah</div>'
* @param str
*/
unescapeHTML(str: string): string;
/**
* Escape a string for use in a regular expression.
* @param str
*/
escapeRegExp(str: string): string;
/**
* Splice a string like an array.
* @param str
* @param i
* @param howmany
* @param substr
*/
splice(str: string, i: number, howmany: number, substr?: string): string;
/**
* Insert a string at index.
* @param str
* @param i
* @param substr
*/
insert(str: string, i: number, substr: string): string;
/**
* Joins strings together with given separator.
* (' ', 'foo', 'bar') => 'foo bar'
* @param separator
* @param args
*/
join(separator: string, ...args: string[]): string;
/**
* Split string by newlines character.
* ('Hello\nWorld') => ['Hello', 'World']
* @param str
*/
lines(str: string): any[];
/**
* Checks if string starts with another string.
* ('image.gif', 'image') => true
* @param str
* @param starts
*/
startsWith(str: string, starts: string): boolean;
/**
* Checks if string ends with another string.
* ('image.gif', 'gif') => true
* @param value
* @param starts
*/
endsWith(value: string, starts: string): boolean;
/**
* Returns the successor to passed string.
* ('a') => 'b'
* @param str
*/
succ(str: string): string;
/**
* Capitalize first letter of every word in the string.
* ('my name is epeli') => 'My Name Is Epeli'
* @param str
*/
titleize(str: string): string;
/**
* Converts underscored or dasherized string to a camelized one.
* ('-moz-transform') => 'MozTransform'
* @param str
*/
camelize(str: string): string;
/**
* Converts a camelized or dasherized string into an underscored one.
* ('MozTransform') => 'moz_transform'
* @param str
*/
underscored(str: string): string;
/**
* Converts a underscored or camelized string into an dasherized one.
* ('MozTransform') => '-moz-transform'
* @param str
*/
dasherize(str: string): string;
/**
* Converts string to camelized class name.
* ('some_class_name') => 'SomeClassName'
* @param str
*/
classify(str: string): string;
/**
* Converts an underscored, camelized, or dasherized string into a humanized one.
* Also removes beginning and ending whitespace, and removes the postfix '_id'.
* (' capitalize dash-CamelCase_underscore trim ') => 'Capitalize dash camel case underscore trim'
* @param str
*/
humanize(str: string): string;
/**
* Trims defined characters from begining and ending of the string.
* Defaults to whitespace characters.
* (' foobar ') => 'foobar'
* ('_-foobar-_', '_-') => 'foobar'
* @param str
* @param characters
*/
trim(str: string, characters?: string): string;
/**
* Trims defined characters from begining and ending of the string.
* Defaults to whitespace characters.
* (' foobar ') => 'foobar'
* ('_-foobar-_', '_-') => 'foobar'
* @param str
* @param characters
*/
strip(str: string, characters?: string): string;
/**
* Left trim. Similar to trim, but only for left side.
* @param str
* @param characters
*/
ltrim(str: string, characters?: string): string;
/**
* Left trim. Similar to trim, but only for left side.
* @param str
* @param characters
*/
lstrip(str: string, characters?: string): string;
/**
* Right trim. Similar to trim, but only for right side.
* @param str
* @param characters
*/
rtrim(str: string, characters?: string): string;
/**
* Right trim. Similar to trim, but only for right side.
* @param str
* @param characters
*/
rstrip(str: string, characters?: string): string;
/**
* Truncate string to specified length.
* ('Hello world').truncate(5) => 'Hello...'
* ('Hello').truncate(10) => 'Hello'
* @param str
* @param length
* @param truncateStr
*/
truncate(str: string, length: number, truncateStr?: string): string;
/**
* Elegant version of truncate.
* Makes sure the pruned string does not exceed the original length.
* Avoid half-chopped words when truncating.
* ('Hello, cruel world', 15) => 'Hello, cruel...'
* @param str
* @param length
* @param pruneStr
*/
prune(str: string, length: number, pruneStr?: string): string;
/**
* Split string by delimiter (String or RegExp).
* /\s+/ by default.
* (' I love you ') => ['I','love','you']
* ('I_love_you', '_') => ['I','love','you']
* @param str
* @param delimiter
*/
words(str: string): string[];
/**
* Split string by delimiter (String or RegExp).
* /\s+/ by default.
* (' I love you ') => ['I','love','you']
* ('I_love_you', '_') => ['I','love','you']
* @param str
* @param delimiter
*/
words(str: string, delimiter: string): string[];
/**
* Split string by delimiter (String or RegExp).
* /\s+/ by default.
* (' I love you ') => ['I','love','you']
* ('I_love_you', '_') => ['I','love','you']
* @param str
* @param delimiter
*/
words(str: string, delimiter: RegExp): string[];
/**
* Pads a string with characters until the total string length is equal to the passed length parameter.
* By default, pads on the left with the space char (' ').
* padStr is truncated to a single character if necessary.
* ('1', 8) => ' 1'
* ('1', 8, '0') => '00000001'
* ('1', 8, '0', 'right') => '10000000'
* ('1', 8, '0', 'both') => '00001000'
* ('1', 8, 'bleepblorp', 'both') => 'bbbb1bbb'
* @param str
* @param length
* @param padStr
* @param type
*/
pad(str: string, length: number, padStr?:string, type?: string): string;
/**
* Left-pad a string.
* Alias for pad(str, length, padStr, 'left')
* ('1', 8, '0') => '00000001'
* @param str
* @param length
* @param padStr
*/
lpad(str: string, length: number, padStr?: string): string;
/**
* Left-pad a string.
* Alias for pad(str, length, padStr, 'left')
* ('1', 8, '0') => '00000001'
* @param str
* @param length
* @param padStr
*/
rjust(str: string, length: number, padStr?: string): string;
/**
* Right-pad a string.
* Alias for pad(str, length, padStr, 'right')
* ('1', 8, '0') => '10000000'
* @param str
* @param length
* @param padStr
*/
rpad(str: string, length: number, padStr?: string): string;
/**
* Right-pad a string.
* Alias for pad(str, length, padStr, 'right')
* ('1', 8, '0') => '10000000'
* @param str
* @param length
* @param padStr
*/
ljust(str: string, length: number, padStr?: string): string;
/**
* Left/right-pad a string.
* Alias for pad(str, length, padStr, 'both')
* ('1', 8, '0') => '00001000'
* @param str
* @param length
* @param padStr
*/
lrpad(str: string, length: number, padStr?: string): string;
/**
* Left/right-pad a string.
* Alias for pad(str, length, padStr, 'both')
* ('1', 8, '0') => '00001000'
* @param str
* @param length
* @param padStr
*/
center(str: string, length: number, padStr?: string): string;
/**
* C like string formatting.
* _.sprintf('%.1f', 1.17) => '1.2'
* @param format
* @param args
*/
sprintf(format: string, ...args: any[]): string;
/**
* Parse string to number.
* Returns NaN if string can't be parsed to number.
* ('2.556').toNumber() => 3
* ('2.556').toNumber(1) => 2.6
* @param str
* @param decimals
*/
toNumber(str: string, decimals?: number): number;
/**
* Formats the numbers.
* (1000, 2) => '1,000.00'
* (123456789.123, 5, '.', ',') => '123,456,789.12300'
* @param number
* @param dec
* @param dsep
* @param tsep
*/
numberFormat(number: number, dec?: number, dsep?: string, tsep?: string): string;
/**
* Searches a string from left to right for a pattern.
* Returns a substring consisting of the characters in the string that are to the right of the pattern.
* If no match found, returns entire string.
* ('This_is_a_test_string').strRight('_') => 'is_a_test_string'
* @param str
* @param sep
*/
strRight(str: string, sep: string): string;
/**
* Searches a string from right to left for a pattern.
* Returns a substring consisting of the characters in the string that are to the right of the pattern.
* If no match found, returns entire string.
* ('This_is_a_test_string').strRightBack('_') => 'string'
* @param str
* @param sep
*/
strRightBack(str: string, sep: string): string;
/**
* Searches a string from left to right for a pattern.
* Returns a substring consisting of the characters in the string that are to the left of the pattern.
* If no match found, returns entire string.
* ('This_is_a_test_string').strLeft('_') => 'This'
* @param str
* @param sep
*/
strLeft(str: string, sep: string): string;
/**
* Searches a string from right to left for a pattern.
* Returns a substring consisting of the characters in the string that are to the left of the pattern.
* If no match found, returns entire string.
* ('This_is_a_test_string').strLeftBack('_') => 'This_is_a_test'
* @param str
* @param sep
*/
strLeftBack(str: string, sep: string): string;
/**
* Join an array into a human readable sentence.
* (['jQuery', 'Mootools', 'Prototype']) => 'jQuery, Mootools and Prototype'
* (['jQuery', 'Mootools', 'Prototype'], ', ', ' unt ') => 'jQuery, Mootools unt Prototype'
* @param array
* @param separator
* @param lastSeparator
* @param serial
*/
toSentence(array: any[], separator?: string, lastSeparator?: string, serial?: boolean): string;
/**
* The same as toSentence, but uses ', ' as default for lastSeparator.
* @param array
* @param separator
* @param lastSeparator
*/
toSentenceSerial(array: any[], separator?: string, lastSeparator?: string): string;
/**
* Transform text into a URL slug. Replaces whitespaces, accentuated, and special characters with a dash.
* ('Un éléphant à l'orée du bois') => 'un-elephant-a-loree-du-bois'
* @param str
*/
slugify(str: string): string;
/**
* Surround a string with another string.
* ('foo', 'ab') => 'abfooab'
* @param str
* @param wrapper
*/
surround(str: string, wrapper: string): string;
/**
* Quotes a string.
* quoteChar defaults to "
* ('foo') => '"foo"'
* @param str
*/
quote(str: string, quoteChar?: string): string;
/**
* Quotes a string.
* quoteChar defaults to "
* ('foo') => '"foo"'
* @param str
*/
q(str: string, quoteChar?: string): string;
/**
* Unquotes a string.
* quoteChar defaults to "
* ('"foo"') => 'foo'
* ("'foo'", "'") => 'foo'
* @param str
*/
unquote(str: string, quoteChar?: string): string;
/**
* Repeat a string with an optional separator.
* ('foo', 3) => 'foofoofoo'
* ('foo', 3, 'bar') => 'foobarfoobarfoo'
* @param value
* @param count
* @param separator
*/
repeat(value: string, count: number, separator?:string): string;
/**
* Naturally sort strings like humans would do.
* Caution: this function is charset dependent.
* @param str1
* @param str2
*/
naturalCmp(str1: string, str2: string): number;
/**
* Calculates Levenshtein distance between two strings.
* ('kitten', 'kittah') => 2
* @param str1
* @param str2
*/
levenshtein(str1: string, str2: string): number;
/**
* Turn strings that can be commonly considered as booleans to real booleans.
* Such as "true", "false", "1" and "0". This function is case insensitive.
* ('true') => true
* ('FALSE') => false
* ('random') => undefined
* ('truthy', ['truthy'], ['falsy']) => true
* ('true only at start', [/^true/]) => true
* @param str
* @param trueValues
* @param falseValues
*/
toBoolean(str: string, trueValues?: any[], falseValues?: any[]): boolean;
}
declare module 'underscore.string' {
var underscoreString: UnderscoreStringStatic;
export = underscoreString;
}
// TODO interface UnderscoreString extends Underscore<string>

3413
typings/underscore/underscore.d.ts поставляемый Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

1
typings/vscode-typings.d.ts поставляемый Normal file
Просмотреть файл

@ -0,0 +1 @@
/// <reference path="../node_modules/vscode/typings/index.d.ts" />