mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-17 07:13:45 +01:00
debt - remove more unused string utils
This commit is contained in:
@@ -181,10 +181,6 @@ export function endsWith(haystack: string, needle: string): boolean {
|
||||
}
|
||||
}
|
||||
|
||||
export function splice(haystack: string, offset: number, length: number, value: string = ''): string {
|
||||
return haystack.substring(0, offset) + value + haystack.substring(offset + length);
|
||||
}
|
||||
|
||||
export function createRegExp(searchString: string, isRegex: boolean, matchCase: boolean, wholeWord: boolean): RegExp {
|
||||
if (searchString === '') {
|
||||
throw new Error('Cannot create regex from empty string');
|
||||
@@ -246,22 +242,6 @@ export function normalizeNFC(str: string, cache?:{[str: string]: string}): strin
|
||||
return res;
|
||||
}
|
||||
|
||||
export function encodeURIPart(haystack: string, keepSlashes?: boolean): string {
|
||||
if (!haystack) {
|
||||
return haystack;
|
||||
}
|
||||
|
||||
if (!keepSlashes) {
|
||||
return encodeURIComponent(haystack);
|
||||
} else {
|
||||
var parts = haystack.split('/');
|
||||
for (var i = 0, len = parts.length; i < len; i++) {
|
||||
parts[i] = encodeURIComponent(parts[i]);
|
||||
}
|
||||
return parts.join('/');
|
||||
}
|
||||
}
|
||||
|
||||
export function isCamelCasePattern(pattern: string): boolean {
|
||||
return (/^\w[\w.]*$/).test(pattern);
|
||||
}
|
||||
@@ -288,21 +268,6 @@ export function assertRegExp(pattern: string, modifiers: string): void {
|
||||
}
|
||||
}
|
||||
|
||||
export function normalizePath(path?: string): string {
|
||||
|
||||
// No path provided, assume root
|
||||
if (!path) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Paths must not start with a slash because they are always relative to the workspace root
|
||||
if (path.indexOf('/') === 0) {
|
||||
path = path.substring(1);
|
||||
}
|
||||
|
||||
return encodeURIPart(path, true);
|
||||
}
|
||||
|
||||
export function colorize(code: number, value: string): string {
|
||||
return '\x1b[' + code + 'm' + value + '\x1b[0m';
|
||||
};
|
||||
|
||||
@@ -91,13 +91,6 @@ suite('Strings', () => {
|
||||
assert(strings.startsWith("", ""));
|
||||
});
|
||||
|
||||
test("splice", function () {
|
||||
assert.equal(strings.splice('boo', 1, 2, 'far'), 'bfar');
|
||||
assert.equal(strings.splice('boo', 0, 2), 'o');
|
||||
assert.equal(strings.splice('boo', 0, 3, 'far'), 'far');
|
||||
assert.equal(strings.splice('boo', 3, 0, 'far'), 'boofar');
|
||||
});
|
||||
|
||||
test("endsWith", function () {
|
||||
assert(strings.endsWith("foo", "o"));
|
||||
assert(strings.endsWith("foo", "oo"));
|
||||
@@ -153,14 +146,6 @@ suite('Strings', () => {
|
||||
assert.strictEqual(" ".trim(), "");
|
||||
});
|
||||
|
||||
test("uri encode with slashes", function () {
|
||||
var str = strings.encodeURIPart("hello &/ world");
|
||||
assert.strictEqual(str, "hello%20%26%2F%20world");
|
||||
|
||||
str = strings.encodeURIPart("hello &/ world", true);
|
||||
assert.strictEqual(str, "hello%20%26/%20world");
|
||||
});
|
||||
|
||||
test("localeCompare", function() {
|
||||
assert.strictEqual(strings.localeCompare('a', 'a'), 'a'.localeCompare('a'));
|
||||
assert.strictEqual(strings.localeCompare('A', 'A'), 'A'.localeCompare('A'));
|
||||
|
||||
Reference in New Issue
Block a user