Revert codestyle changes (#40)

* Revert "7f7efbb94bab8574e42d942ad82d414e007b2970"

Code style changes should probably be part of a PR
This commit is contained in:
Eliot Partridge
2019-08-30 10:53:14 -05:00
committed by GitHub
parent eefd9e9a2c
commit caf70a864f
446 changed files with 70667 additions and 70655 deletions
+45 -45
View File
@@ -3,88 +3,88 @@ const uppercaseCharacters = lowercaseCharacters + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
const CARRIAGERETURN = '\r'.charCodeAt(0);
export function randomString(length: number, useUpperCase = false): string {
const characters = useUpperCase ? uppercaseCharacters : lowercaseCharacters;
let result = '';
const characters = useUpperCase ? uppercaseCharacters : lowercaseCharacters;
let result = '';
for (let i = 0; i < length; i++) {
result += characters[(Math.random() * characters.length) | 0];
}
for (let i = 0; i < length; i++) {
result += characters[(Math.random() * characters.length) | 0];
}
return result;
return result;
}
export function isSurrogate(code: number): boolean {
return code >= 0xd800 && code <= 0xdbff;
return code >= 0xd800 && code <= 0xdbff;
}
export function isLowSurrogate(code: number): boolean {
return (code & 0xfc00) === 0xdc00;
return (code & 0xfc00) === 0xdc00;
}
export function fromSurrogate(high: number, low: number): number {
return (((high & 0x3ff) << 10) + (low & 0x3ff) + 0x10000) | 0;
return (((high & 0x3ff) << 10) + (low & 0x3ff) + 0x10000) | 0;
}
export function charsToCodes(text: string) {
const chars: number[] = [];
const chars: number[] = [];
for (let i = 0; i < text.length; i++) {
let code = text.charCodeAt(i);
for (let i = 0; i < text.length; i++) {
let code = text.charCodeAt(i);
if (isSurrogate(code) && (i + 1) < text.length) {
const extra = text.charCodeAt(i + 1);
if (isSurrogate(code) && (i + 1) < text.length) {
const extra = text.charCodeAt(i + 1);
if (isLowSurrogate(extra)) {
code = fromSurrogate(code, extra);
i++;
}
}
if (isLowSurrogate(extra)) {
code = fromSurrogate(code, extra);
i++;
}
}
chars.push(code);
}
chars.push(code);
}
return chars;
return chars;
}
export function stringToCodes(buffer: Uint32Array, text: string): number {
const textLength = text.length | 0;
let length = 0 | 0;
const textLength = text.length | 0;
let length = 0 | 0;
for (let i = 0; i < textLength; i = (i + 1) | 0) {
let code = text.charCodeAt(i) | 0;
for (let i = 0; i < textLength; i = (i + 1) | 0) {
let code = text.charCodeAt(i) | 0;
if (isSurrogate(code) && ((i + 1) | 0) < textLength) {
const extra = text.charCodeAt(i + 1) | 0;
if (isSurrogate(code) && ((i + 1) | 0) < textLength) {
const extra = text.charCodeAt(i + 1) | 0;
if (isLowSurrogate(extra)) {
code = fromSurrogate(code, extra) | 0;
i = (i + 1) | 0;
}
}
if (isLowSurrogate(extra)) {
code = fromSurrogate(code, extra) | 0;
i = (i + 1) | 0;
}
}
if (isVisibleChar(code)) {
buffer[length] = code;
length = (length + 1) | 0;
}
}
if (isVisibleChar(code)) {
buffer[length] = code;
length = (length + 1) | 0;
}
}
return length;
return length;
}
export let codesBuffer = new Uint32Array(32);
export function stringToCodesTemp(text: string) {
while (text.length > codesBuffer.length) {
codesBuffer = new Uint32Array(codesBuffer.length * 2);
}
while (text.length > codesBuffer.length) {
codesBuffer = new Uint32Array(codesBuffer.length * 2);
}
return stringToCodes(codesBuffer, text);
return stringToCodes(codesBuffer, text);
}
export function matcher(regex: RegExp) {
return (text: string): boolean => !!text && regex.test(text);
return (text: string): boolean => !!text && regex.test(text);
}
export function isVisibleChar(code: number) {
return code !== CARRIAGERETURN && !(code >= 0xfe00 && code <= 0xfe0f);
return code !== CARRIAGERETURN && !(code >= 0xfe00 && code <= 0xfe0f);
}