提交 2c5a0544 编写于 作者: J Johannes Rieken

remove some unused bits, #38414

上级 e7ceef9f
......@@ -618,20 +618,6 @@ export function isFullWidthCharacter(charCode: number): boolean {
);
}
/**
* Returns an array in which every entry is the offset of a
* line. There is always one entry which is zero.
*/
export function computeLineStarts(text: string): number[] {
let regexp = /\r\n|\r|\n/g,
ret: number[] = [0],
match: RegExpExecArray;
while ((match = regexp.exec(text))) {
ret.push(regexp.lastIndex);
}
return ret;
}
/**
* Given a string and a max length returns a shorted version. Shorting
* happens at favorable positions - such as whitespace or punctuation characters.
......@@ -683,25 +669,6 @@ export function stripUTF8BOM(str: string): string {
return startsWithUTF8BOM(str) ? str.substr(1) : str;
}
/**
* Appends two strings. If the appended result is longer than maxLength,
* trims the start of the result and replaces it with '...'.
*/
export function appendWithLimit(first: string, second: string, maxLength: number): string {
const newLength = first.length + second.length;
if (newLength > maxLength) {
first = '...' + first.substr(newLength - maxLength);
}
if (second.length > maxLength) {
first += second.substr(second.length - maxLength);
} else {
first += second;
}
return first;
}
export function safeBtoa(str: string): string {
return btoa(encodeURIComponent(str)); // we use encodeURIComponent because btoa fails for non Latin 1 values
}
......
......@@ -13,8 +13,6 @@ export interface UUID {
* @returns the canonical representation in sets of hexadecimal numbers separated by dashes.
*/
asHex(): string;
equals(other: UUID): boolean;
}
class ValueUUID implements UUID {
......@@ -26,10 +24,6 @@ class ValueUUID implements UUID {
public asHex(): string {
return this._value;
}
public equals(other: UUID): boolean {
return this.asHex() === other.asHex();
}
}
class V4UUID extends ValueUUID {
......
......@@ -103,29 +103,6 @@ suite('Strings', () => {
assert.equal(strings.overlap('full', 'full'), 4);
assert.equal(strings.overlap('full', 'fulloverlap'), 4);
});
test('computeLineStarts', function () {
function assertLineStart(text: string, ...offsets: number[]): void {
const actual = strings.computeLineStarts(text);
assert.equal(actual.length, offsets.length);
if (actual.length !== offsets.length) {
return;
}
while (offsets.length > 0) {
assert.equal(actual.pop(), offsets.pop());
}
}
assertLineStart('', 0);
assertLineStart('farboo', 0);
assertLineStart('far\nboo', 0, 4);
assertLineStart('far\rboo', 0, 4);
assertLineStart('far\r\nboo', 0, 5);
assertLineStart('far\n\rboo', 0, 4, 5);
assertLineStart('far\n \rboo', 0, 4, 6);
assertLineStart('far\nboo\nfar', 0, 4, 8);
});
test('lcut', () => {
assert.strictEqual(strings.lcut('foo bar', 0), '');
assert.strictEqual(strings.lcut('foo bar', 1), 'bar');
......@@ -218,13 +195,6 @@ suite('Strings', () => {
assert.strictEqual(' '.trim(), '');
});
test('appendWithLimit', function () {
assert.strictEqual(strings.appendWithLimit('ab', 'cd', 100), 'abcd');
assert.strictEqual(strings.appendWithLimit('ab', 'cd', 2), '...cd');
assert.strictEqual(strings.appendWithLimit('ab', 'cdefgh', 4), '...efgh');
assert.strictEqual(strings.appendWithLimit('abcdef', 'ghijk', 7), '...efghijk');
});
test('repeat', () => {
assert.strictEqual(strings.repeat(' ', 4), ' ');
assert.strictEqual(strings.repeat(' ', 1), ' ');
......
......@@ -12,14 +12,13 @@ suite('UUID', () => {
var asHex = uuid.v4().asHex();
assert.equal(asHex.length, 36);
assert.equal(asHex[14], '4');
assert(asHex[19] === '8' || asHex[19] === '9' || asHex[19] === 'a' || asHex[19] === 'b');
assert.ok(asHex[19] === '8' || asHex[19] === '9' || asHex[19] === 'a' || asHex[19] === 'b');
});
test('parse', () => {
var id = uuid.v4();
var asHext = id.asHex();
var id2 = uuid.parse(asHext);
assert(id.equals(id2));
assert(id2.equals(id));
assert.equal(id.asHex(), id2.asHex());
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册