Skip to content

Commit

Permalink
fix: Use as any on globalThis.Buffer check. (#1004)
Browse files Browse the repository at this point in the history
See #967.
  • Loading branch information
stephenh authored Feb 17, 2024
1 parent 22e2996 commit 11d06b4
Show file tree
Hide file tree
Showing 25 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ function bytesFromBase64(b64: string): Uint8Array {
}

function base64FromBytes(arr: Uint8Array): string {
if (globalThis.Buffer) {
if ((globalThis as any).Buffer) {
return globalThis.Buffer.from(arr).toString("base64");
} else {
const bin: string[] = [];
Expand Down
2 changes: 1 addition & 1 deletion integration/bytes-as-base64/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function bytesFromBase64(b64: string): Uint8Array {
}

function base64FromBytes(arr: Uint8Array): string {
if (globalThis.Buffer) {
if ((globalThis as any).Buffer) {
return globalThis.Buffer.from(arr).toString("base64");
} else {
const bin: string[] = [];
Expand Down
2 changes: 1 addition & 1 deletion integration/emit-default-values-json/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ function bytesFromBase64(b64: string): Uint8Array {
}

function base64FromBytes(arr: Uint8Array): string {
if (globalThis.Buffer) {
if ((globalThis as any).Buffer) {
return globalThis.Buffer.from(arr).toString("base64");
} else {
const bin: string[] = [];
Expand Down
2 changes: 1 addition & 1 deletion integration/grpc-js/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ function bytesFromBase64(b64: string): Uint8Array {
}

function base64FromBytes(arr: Uint8Array): string {
if (globalThis.Buffer) {
if ((globalThis as any).Buffer) {
return globalThis.Buffer.from(arr).toString("base64");
} else {
const bin: string[] = [];
Expand Down
2 changes: 1 addition & 1 deletion integration/grpc-web/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ function bytesFromBase64(b64: string): Uint8Array {
}

function base64FromBytes(arr: Uint8Array): string {
if (globalThis.Buffer) {
if ((globalThis as any).Buffer) {
return globalThis.Buffer.from(arr).toString("base64");
} else {
const bin: string[] = [];
Expand Down
2 changes: 1 addition & 1 deletion integration/nice-grpc/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ function bytesFromBase64(b64: string): Uint8Array {
}

function base64FromBytes(arr: Uint8Array): string {
if (globalThis.Buffer) {
if ((globalThis as any).Buffer) {
return globalThis.Buffer.from(arr).toString("base64");
} else {
const bin: string[] = [];
Expand Down
2 changes: 1 addition & 1 deletion integration/oneof-properties/oneof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ function bytesFromBase64(b64: string): Uint8Array {
}

function base64FromBytes(arr: Uint8Array): string {
if (globalThis.Buffer) {
if ((globalThis as any).Buffer) {
return globalThis.Buffer.from(arr).toString("base64");
} else {
const bin: string[] = [];
Expand Down
2 changes: 1 addition & 1 deletion integration/oneof-unions/oneof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ function bytesFromBase64(b64: string): Uint8Array {
}

function base64FromBytes(arr: Uint8Array): string {
if (globalThis.Buffer) {
if ((globalThis as any).Buffer) {
return globalThis.Buffer.from(arr).toString("base64");
} else {
const bin: string[] = [];
Expand Down
2 changes: 1 addition & 1 deletion integration/output-toJSON-only/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export const BytesValue = {
};

function base64FromBytes(arr: Uint8Array): string {
if (globalThis.Buffer) {
if ((globalThis as any).Buffer) {
return globalThis.Buffer.from(arr).toString("base64");
} else {
const bin: string[] = [];
Expand Down
2 changes: 1 addition & 1 deletion integration/simple-long-bigint/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ function bytesFromBase64(b64: string): Uint8Array {
}

function base64FromBytes(arr: Uint8Array): string {
if (globalThis.Buffer) {
if ((globalThis as any).Buffer) {
return globalThis.Buffer.from(arr).toString("base64");
} else {
const bin: string[] = [];
Expand Down
2 changes: 1 addition & 1 deletion integration/simple-long-string/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ function bytesFromBase64(b64: string): Uint8Array {
}

function base64FromBytes(arr: Uint8Array): string {
if (globalThis.Buffer) {
if ((globalThis as any).Buffer) {
return globalThis.Buffer.from(arr).toString("base64");
} else {
const bin: string[] = [];
Expand Down
2 changes: 1 addition & 1 deletion integration/simple-long/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ function bytesFromBase64(b64: string): Uint8Array {
}

function base64FromBytes(arr: Uint8Array): string {
if (globalThis.Buffer) {
if ((globalThis as any).Buffer) {
return globalThis.Buffer.from(arr).toString("base64");
} else {
const bin: string[] = [];
Expand Down
2 changes: 1 addition & 1 deletion integration/simple-optionals/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ function bytesFromBase64(b64: string): Uint8Array {
}

function base64FromBytes(arr: Uint8Array): string {
if (globalThis.Buffer) {
if ((globalThis as any).Buffer) {
return globalThis.Buffer.from(arr).toString("base64");
} else {
const bin: string[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ function bytesFromBase64(b64: string): Uint8Array {
}

function base64FromBytes(arr: Uint8Array): string {
if (globalThis.Buffer) {
if ((globalThis as any).Buffer) {
return globalThis.Buffer.from(arr).toString("base64");
} else {
const bin: string[] = [];
Expand Down
2 changes: 1 addition & 1 deletion integration/simple-prototype-defaults/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2926,7 +2926,7 @@ function bytesFromBase64(b64: string): Uint8Array {
}

function base64FromBytes(arr: Uint8Array): string {
if (globalThis.Buffer) {
if ((globalThis as any).Buffer) {
return globalThis.Buffer.from(arr).toString("base64");
} else {
const bin: string[] = [];
Expand Down
2 changes: 1 addition & 1 deletion integration/simple-snake/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ function bytesFromBase64(b64: string): Uint8Array {
}

function base64FromBytes(arr: Uint8Array): string {
if (globalThis.Buffer) {
if ((globalThis as any).Buffer) {
return globalThis.Buffer.from(arr).toString("base64");
} else {
const bin: string[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ function bytesFromBase64(b64: string): Uint8Array {
}

function base64FromBytes(arr: Uint8Array): string {
if (globalThis.Buffer) {
if ((globalThis as any).Buffer) {
return globalThis.Buffer.from(arr).toString("base64");
} else {
const bin: string[] = [];
Expand Down
2 changes: 1 addition & 1 deletion integration/simple/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ function bytesFromBase64(b64: string): Uint8Array {
}

function base64FromBytes(arr: Uint8Array): string {
if (globalThis.Buffer) {
if ((globalThis as any).Buffer) {
return globalThis.Buffer.from(arr).toString("base64");
} else {
const bin: string[] = [];
Expand Down
2 changes: 1 addition & 1 deletion integration/simple/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3048,7 +3048,7 @@ function bytesFromBase64(b64: string): Uint8Array {
}

function base64FromBytes(arr: Uint8Array): string {
if (globalThis.Buffer) {
if ((globalThis as any).Buffer) {
return globalThis.Buffer.from(arr).toString("base64");
} else {
const bin: string[] = [];
Expand Down
2 changes: 1 addition & 1 deletion integration/use-map-type/use-map-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ function bytesFromBase64(b64: string): Uint8Array {
}

function base64FromBytes(arr: Uint8Array): string {
if (globalThis.Buffer) {
if ((globalThis as any).Buffer) {
return globalThis.Buffer.from(arr).toString("base64");
} else {
const bin: string[] = [];
Expand Down
2 changes: 1 addition & 1 deletion integration/use-optionals-all/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ function bytesFromBase64(b64: string): Uint8Array {
}

function base64FromBytes(arr: Uint8Array): string {
if (globalThis.Buffer) {
if ((globalThis as any).Buffer) {
return globalThis.Buffer.from(arr).toString("base64");
} else {
const bin: string[] = [];
Expand Down
2 changes: 1 addition & 1 deletion integration/use-optionals-no-undefined/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ function bytesFromBase64(b64: string): Uint8Array {
}

function base64FromBytes(arr: Uint8Array): string {
if (globalThis.Buffer) {
if ((globalThis as any).Buffer) {
return globalThis.Buffer.from(arr).toString("base64");
} else {
const bin: string[] = [];
Expand Down
2 changes: 1 addition & 1 deletion integration/value/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ function bytesFromBase64(b64: string): Uint8Array {
}

function base64FromBytes(arr: Uint8Array): string {
if (globalThis.Buffer) {
if ((globalThis as any).Buffer) {
return globalThis.Buffer.from(arr).toString("base64");
} else {
const bin: string[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ function bytesFromBase64(b64: string): Uint8Array {
}

function base64FromBytes(arr: Uint8Array): string {
if (globalThis.Buffer) {
if ((globalThis as any).Buffer) {
return globalThis.Buffer.from(arr).toString("base64");
} else {
const bin: string[] = [];
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ function makeByteUtils(options: Options) {
return base64FromBytesBrowserSnippet;
default:
return code`
if (${globalThis}.Buffer) {
if ((${globalThis} as any).Buffer) {
${base64FromBytesNodeSnippet}
} else {
${base64FromBytesBrowserSnippet}
Expand Down

0 comments on commit 11d06b4

Please sign in to comment.