diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2020-07-14 15:24:17 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-14 15:24:17 -0400 |
commit | cde4dbb35132848ffece59ef9cfaccff32347124 (patch) | |
tree | cc7830968c6decde704c8cfb83c9185193dc698f /cli/js/web/base64.ts | |
parent | 9eca71caa1674c31f9cc5d4e86c03f10b59e0a00 (diff) |
Use dprint for internal formatting (#6682)
Diffstat (limited to 'cli/js/web/base64.ts')
-rw-r--r-- | cli/js/web/base64.ts | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/cli/js/web/base64.ts b/cli/js/web/base64.ts index 328311d03..6f2459b92 100644 --- a/cli/js/web/base64.ts +++ b/cli/js/web/base64.ts @@ -45,7 +45,7 @@ export function byteLength(b64: string): number { function _byteLength( b64: string, validLen: number, - placeHoldersLen: number + placeHoldersLen: number, ): number { return ((validLen + placeHoldersLen) * 3) / 4 - placeHoldersLen; } @@ -65,8 +65,7 @@ export function toByteArray(b64: string): Uint8Array { let i; for (i = 0; i < len; i += 4) { - tmp = - (revLookup[b64.charCodeAt(i)] << 18) | + tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]; @@ -76,15 +75,13 @@ export function toByteArray(b64: string): Uint8Array { } if (placeHoldersLen === 2) { - tmp = - (revLookup[b64.charCodeAt(i)] << 2) | + tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4); arr[curByte++] = tmp & 0xff; } if (placeHoldersLen === 1) { - tmp = - (revLookup[b64.charCodeAt(i)] << 10) | + tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2); arr[curByte++] = (tmp >> 8) & 0xff; @@ -107,8 +104,7 @@ function encodeChunk(uint8: Uint8Array, start: number, end: number): string { let tmp; const output = []; for (let i = start; i < end; i += 3) { - tmp = - ((uint8[i] << 16) & 0xff0000) + + tmp = ((uint8[i] << 16) & 0xff0000) + ((uint8[i + 1] << 8) & 0xff00) + (uint8[i + 2] & 0xff); output.push(tripletToBase64(tmp)); @@ -129,8 +125,8 @@ export function fromByteArray(uint8: Uint8Array): string { encodeChunk( uint8, i, - i + maxChunkLength > len2 ? len2 : i + maxChunkLength - ) + i + maxChunkLength > len2 ? len2 : i + maxChunkLength, + ), ); } @@ -144,7 +140,7 @@ export function fromByteArray(uint8: Uint8Array): string { lookup[tmp >> 10] + lookup[(tmp >> 4) & 0x3f] + lookup[(tmp << 2) & 0x3f] + - "=" + "=", ); } |