Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use Uint8Array.forEach in base64FromBytes #544

Merged
merged 2 commits into from
Apr 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions integration/bytes-as-base64/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ const btoa: (bin: string) => string =
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr: Uint8Array): string {
const bin: string[] = [];
for (const byte of arr) {
arr.forEach((byte) => {
bin.push(String.fromCharCode(byte));
}
});
return btoa(bin.join(''));
}

Expand Down
4 changes: 2 additions & 2 deletions integration/bytes-node/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -562,9 +562,9 @@ const btoa: (bin: string) => string =
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr: Uint8Array): string {
const bin: string[] = [];
for (const byte of arr) {
arr.forEach((byte) => {
bin.push(String.fromCharCode(byte));
}
});
return btoa(bin.join(''));
}

Expand Down
4 changes: 2 additions & 2 deletions integration/bytes-node/point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ const btoa: (bin: string) => string =
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr: Uint8Array): string {
const bin: string[] = [];
for (const byte of arr) {
arr.forEach((byte) => {
bin.push(String.fromCharCode(byte));
}
});
return btoa(bin.join(''));
}

Expand Down
4 changes: 2 additions & 2 deletions integration/grpc-js/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -562,9 +562,9 @@ const btoa: (bin: string) => string =
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr: Uint8Array): string {
const bin: string[] = [];
for (const byte of arr) {
arr.forEach((byte) => {
bin.push(String.fromCharCode(byte));
}
});
return btoa(bin.join(''));
}

Expand Down
4 changes: 2 additions & 2 deletions integration/oneof-properties/oneof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ const btoa: (bin: string) => string =
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr: Uint8Array): string {
const bin: string[] = [];
for (const byte of arr) {
arr.forEach((byte) => {
bin.push(String.fromCharCode(byte));
}
});
return btoa(bin.join(''));
}

Expand Down
4 changes: 2 additions & 2 deletions integration/oneof-unions/oneof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,9 @@ const btoa: (bin: string) => string =
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr: Uint8Array): string {
const bin: string[] = [];
for (const byte of arr) {
arr.forEach((byte) => {
bin.push(String.fromCharCode(byte));
}
});
return btoa(bin.join(''));
}

Expand Down
4 changes: 2 additions & 2 deletions integration/simple-long-string/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -562,9 +562,9 @@ const btoa: (bin: string) => string =
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr: Uint8Array): string {
const bin: string[] = [];
for (const byte of arr) {
arr.forEach((byte) => {
bin.push(String.fromCharCode(byte));
}
});
return btoa(bin.join(''));
}

Expand Down
4 changes: 2 additions & 2 deletions integration/simple-long/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -562,9 +562,9 @@ const btoa: (bin: string) => string =
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr: Uint8Array): string {
const bin: string[] = [];
for (const byte of arr) {
arr.forEach((byte) => {
bin.push(String.fromCharCode(byte));
}
});
return btoa(bin.join(''));
}

Expand Down
4 changes: 2 additions & 2 deletions integration/simple-optionals/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -562,9 +562,9 @@ const btoa: (bin: string) => string =
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr: Uint8Array): string {
const bin: string[] = [];
for (const byte of arr) {
arr.forEach((byte) => {
bin.push(String.fromCharCode(byte));
}
});
return btoa(bin.join(''));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,9 +562,9 @@ const btoa: (bin: string) => string =
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr: Uint8Array): string {
const bin: string[] = [];
for (const byte of arr) {
arr.forEach((byte) => {
bin.push(String.fromCharCode(byte));
}
});
return btoa(bin.join(''));
}

Expand Down
4 changes: 2 additions & 2 deletions integration/simple-prototype-defaults/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2369,9 +2369,9 @@ const btoa: (bin: string) => string =
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr: Uint8Array): string {
const bin: string[] = [];
for (const byte of arr) {
arr.forEach((byte) => {
bin.push(String.fromCharCode(byte));
}
});
return btoa(bin.join(''));
}

Expand Down
4 changes: 2 additions & 2 deletions integration/simple-snake/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -562,9 +562,9 @@ const btoa: (bin: string) => string =
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr: Uint8Array): string {
const bin: string[] = [];
for (const byte of arr) {
arr.forEach((byte) => {
bin.push(String.fromCharCode(byte));
}
});
return btoa(bin.join(''));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,9 +562,9 @@ const btoa: (bin: string) => string =
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr: Uint8Array): string {
const bin: string[] = [];
for (const byte of arr) {
arr.forEach((byte) => {
bin.push(String.fromCharCode(byte));
}
});
return btoa(bin.join(''));
}

Expand Down
4 changes: 2 additions & 2 deletions integration/simple/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -562,9 +562,9 @@ const btoa: (bin: string) => string =
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr: Uint8Array): string {
const bin: string[] = [];
for (const byte of arr) {
arr.forEach((byte) => {
bin.push(String.fromCharCode(byte));
}
});
return btoa(bin.join(''));
}

Expand Down
4 changes: 2 additions & 2 deletions integration/simple/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2357,9 +2357,9 @@ const btoa: (bin: string) => string =
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr: Uint8Array): string {
const bin: string[] = [];
for (const byte of arr) {
arr.forEach((byte) => {
bin.push(String.fromCharCode(byte));
}
});
return btoa(bin.join(''));
}

Expand Down
4 changes: 2 additions & 2 deletions integration/use-optionals-all/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -563,9 +563,9 @@ const btoa: (bin: string) => string =
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr: Uint8Array): string {
const bin: string[] = [];
for (const byte of arr) {
arr.forEach((byte) => {
bin.push(String.fromCharCode(byte));
}
});
return btoa(bin.join(''));
}

Expand Down
4 changes: 2 additions & 2 deletions integration/value/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -562,9 +562,9 @@ const btoa: (bin: string) => string =
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr: Uint8Array): string {
const bin: string[] = [];
for (const byte of arr) {
arr.forEach((byte) => {
bin.push(String.fromCharCode(byte));
}
});
return btoa(bin.join(''));
}

Expand Down
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,9 @@ function makeByteUtils() {
const btoa : (bin: string) => string = ${globalThis}.btoa || ((bin) => ${globalThis}.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr: Uint8Array): string {
const bin: string[] = [];
for (const byte of arr) {
arr.forEach((byte) => {
bin.push(String.fromCharCode(byte));
}
});
return btoa(bin.join(''));
}
`
Expand Down