Skip to content

Commit

Permalink
feat: support lib: es6 (#850)
Browse files Browse the repository at this point in the history
Co-authored-by: Your Name <you@example.com>
  • Loading branch information
f0rmat1k and Your Name committed Jun 13, 2023
1 parent 9901419 commit 6280677
Show file tree
Hide file tree
Showing 32 changed files with 109 additions and 109 deletions.
8 changes: 4 additions & 4 deletions integration/bytes-as-base64/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ export interface Message {
}

function createBaseMessage(): Message {
return { data: new Uint8Array() };
return { data: new Uint8Array(0) };
}

export const Message = {
fromJSON(object: any): Message {
return { data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array() };
return { data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(0) };
},

toJSON(message: Message): unknown {
const obj: any = {};
message.data !== undefined &&
(obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array()));
(obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array(0)));
return obj;
},

Expand All @@ -28,7 +28,7 @@ export const Message = {

fromPartial<I extends Exact<DeepPartial<Message>, I>>(object: I): Message {
const message = createBaseMessage();
message.data = object.data ?? new Uint8Array();
message.data = object.data ?? new Uint8Array(0);
return message;
},
};
Expand Down
8 changes: 4 additions & 4 deletions integration/grpc-js/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ export const StringValue = {
};

function createBaseBytesValue(): BytesValue {
return { value: new Uint8Array() };
return { value: new Uint8Array(0) };
}

export const BytesValue = {
Expand Down Expand Up @@ -578,13 +578,13 @@ export const BytesValue = {
},

fromJSON(object: any): BytesValue {
return { value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array() };
return { value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(0) };
},

toJSON(message: BytesValue): unknown {
const obj: any = {};
message.value !== undefined &&
(obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array()));
(obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array(0)));
return obj;
},

Expand All @@ -594,7 +594,7 @@ export const BytesValue = {

fromPartial<I extends Exact<DeepPartial<BytesValue>, I>>(object: I): BytesValue {
const message = createBaseBytesValue();
message.value = object.value ?? new Uint8Array();
message.value = object.value ?? new Uint8Array(0);
return message;
},
};
Expand Down
4 changes: 2 additions & 2 deletions integration/grpc-js/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ export const TestService = {
requestStream: false,
responseStream: false,
requestSerialize: (value: Uint8Array | undefined) =>
Buffer.from(BytesValue.encode({ value: value ?? new Uint8Array() }).finish()),
Buffer.from(BytesValue.encode({ value: value ?? new Uint8Array(0) }).finish()),
requestDeserialize: (value: Buffer) => BytesValue.decode(value).value,
responseSerialize: (value: Uint8Array | undefined) =>
Buffer.from(BytesValue.encode({ value: value ?? new Uint8Array() }).finish()),
Buffer.from(BytesValue.encode({ value: value ?? new Uint8Array(0) }).finish()),
responseDeserialize: (value: Buffer) => BytesValue.decode(value).value,
},
unaryFloatValue: {
Expand Down
2 changes: 1 addition & 1 deletion integration/meta-typings/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ export const StringValue = {
};

function createBaseBytesValue(): BytesValue {
return { value: new Uint8Array() };
return { value: new Uint8Array(0) };
}

export const BytesValue = {
Expand Down
4 changes: 2 additions & 2 deletions integration/meta-typings/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ function createBaseSimple(): Simple {
thing: undefined,
blobs: [],
birthday: undefined,
blob: new Uint8Array(),
blob: new Uint8Array(0),
};
}

Expand Down Expand Up @@ -1004,7 +1004,7 @@ export const SimpleWithMap_MapOfTimestampsEntry = {
};

function createBaseSimpleWithMap_MapOfBytesEntry(): SimpleWithMap_MapOfBytesEntry {
return { key: "", value: new Uint8Array() };
return { key: "", value: new Uint8Array(0) };
}

export const SimpleWithMap_MapOfBytesEntry = {
Expand Down
8 changes: 4 additions & 4 deletions integration/nice-grpc/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ export const StringValue = {
};

function createBaseBytesValue(): BytesValue {
return { value: new Uint8Array() };
return { value: new Uint8Array(0) };
}

export const BytesValue = {
Expand Down Expand Up @@ -578,13 +578,13 @@ export const BytesValue = {
},

fromJSON(object: any): BytesValue {
return { value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array() };
return { value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(0) };
},

toJSON(message: BytesValue): unknown {
const obj: any = {};
message.value !== undefined &&
(obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array()));
(obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array(0)));
return obj;
},

Expand All @@ -594,7 +594,7 @@ export const BytesValue = {

fromPartial(object: DeepPartial<BytesValue>): BytesValue {
const message = createBaseBytesValue();
message.value = object.value ?? new Uint8Array();
message.value = object.value ?? new Uint8Array(0);
return message;
},
};
Expand Down
6 changes: 3 additions & 3 deletions integration/oneof-unions/oneof-unions-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('oneof=unions', () => {
age: 37,
choice: { $case: 'aBool', aBool: true },
eitherOr: { $case: 'or', or: 'perhaps not' },
signature: new Uint8Array(),
signature: new Uint8Array(0),
value: 'Debbie'
});
});
Expand Down Expand Up @@ -72,7 +72,7 @@ describe('oneof=unions', () => {
expect(empty).toEqual({
name: '',
age: 0,
signature: new Uint8Array(),
signature: new Uint8Array(0),
});

let partial = PleaseChoose.fromPartial({
Expand Down Expand Up @@ -107,7 +107,7 @@ describe('oneof=unions', () => {

it('fromJSON', () => {
let empty = PleaseChoose.fromJSON({});
expect(empty).toEqual({ age: 0, name: '', signature: new Uint8Array() });
expect(empty).toEqual({ age: 0, name: '', signature: new Uint8Array(0) });

let debbie: PleaseChoose = {
name: 'Debbie',
Expand Down
8 changes: 4 additions & 4 deletions integration/oneof-unions/oneof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export interface SimpleButOptional {
}

function createBasePleaseChoose(): PleaseChoose {
return { name: "", choice: undefined, age: 0, eitherOr: undefined, signature: new Uint8Array(), value: undefined };
return { name: "", choice: undefined, age: 0, eitherOr: undefined, signature: new Uint8Array(0), value: undefined };
}

export const PleaseChoose = {
Expand Down Expand Up @@ -254,7 +254,7 @@ export const PleaseChoose = {
: isSet(object.thirdOption)
? { $case: "thirdOption", thirdOption: String(object.thirdOption) }
: undefined,
signature: isSet(object.signature) ? bytesFromBase64(object.signature) : new Uint8Array(),
signature: isSet(object.signature) ? bytesFromBase64(object.signature) : new Uint8Array(0),
value: isSet(object?.value) ? object.value : undefined,
};
},
Expand All @@ -278,7 +278,7 @@ export const PleaseChoose = {
message.eitherOr?.$case === "or" && (obj.or = message.eitherOr?.or);
message.eitherOr?.$case === "thirdOption" && (obj.thirdOption = message.eitherOr?.thirdOption);
message.signature !== undefined &&
(obj.signature = base64FromBytes(message.signature !== undefined ? message.signature : new Uint8Array()));
(obj.signature = base64FromBytes(message.signature !== undefined ? message.signature : new Uint8Array(0)));
message.value !== undefined && (obj.value = message.value);
return obj;
},
Expand Down Expand Up @@ -330,7 +330,7 @@ export const PleaseChoose = {
) {
message.eitherOr = { $case: "thirdOption", thirdOption: object.eitherOr.thirdOption };
}
message.signature = object.signature ?? new Uint8Array();
message.signature = object.signature ?? new Uint8Array(0);
message.value = object.value ?? undefined;
return message;
},
Expand Down
2 changes: 1 addition & 1 deletion integration/options/google/protobuf/descriptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2559,7 +2559,7 @@ function createBaseUninterpretedOption(): UninterpretedOption {
positiveIntValue: 0,
negativeIntValue: 0,
doubleValue: 0,
stringValue: new Uint8Array(),
stringValue: new Uint8Array(0),
aggregateValue: "",
};
}
Expand Down
2 changes: 1 addition & 1 deletion integration/output-decode-only/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ export const StringValue = {
};

function createBaseBytesValue(): BytesValue {
return { value: new Uint8Array() };
return { value: new Uint8Array(0) };
}

export const BytesValue = {
Expand Down
2 changes: 1 addition & 1 deletion integration/output-encode-only/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export const StringValue = {
};

function createBaseBytesValue(): BytesValue {
return { value: new Uint8Array() };
return { value: new Uint8Array(0) };
}

export const BytesValue = {
Expand Down
8 changes: 4 additions & 4 deletions integration/simple-long-bigint/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ export const StringValue = {
};

function createBaseBytesValue(): BytesValue {
return { value: new Uint8Array() };
return { value: new Uint8Array(0) };
}

export const BytesValue = {
Expand Down Expand Up @@ -578,13 +578,13 @@ export const BytesValue = {
},

fromJSON(object: any): BytesValue {
return { value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array() };
return { value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(0) };
},

toJSON(message: BytesValue): unknown {
const obj: any = {};
message.value !== undefined &&
(obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array()));
(obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array(0)));
return obj;
},

Expand All @@ -594,7 +594,7 @@ export const BytesValue = {

fromPartial<I extends Exact<DeepPartial<BytesValue>, I>>(object: I): BytesValue {
const message = createBaseBytesValue();
message.value = object.value ?? new Uint8Array();
message.value = object.value ?? new Uint8Array(0);
return message;
},
};
Expand Down
8 changes: 4 additions & 4 deletions integration/simple-long-string/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ export const StringValue = {
};

function createBaseBytesValue(): BytesValue {
return { value: new Uint8Array() };
return { value: new Uint8Array(0) };
}

export const BytesValue = {
Expand Down Expand Up @@ -578,13 +578,13 @@ export const BytesValue = {
},

fromJSON(object: any): BytesValue {
return { value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array() };
return { value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(0) };
},

toJSON(message: BytesValue): unknown {
const obj: any = {};
message.value !== undefined &&
(obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array()));
(obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array(0)));
return obj;
},

Expand All @@ -594,7 +594,7 @@ export const BytesValue = {

fromPartial<I extends Exact<DeepPartial<BytesValue>, I>>(object: I): BytesValue {
const message = createBaseBytesValue();
message.value = object.value ?? new Uint8Array();
message.value = object.value ?? new Uint8Array(0);
return message;
},
};
Expand Down
8 changes: 4 additions & 4 deletions integration/simple-long/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ export const StringValue = {
};

function createBaseBytesValue(): BytesValue {
return { value: new Uint8Array() };
return { value: new Uint8Array(0) };
}

export const BytesValue = {
Expand Down Expand Up @@ -578,13 +578,13 @@ export const BytesValue = {
},

fromJSON(object: any): BytesValue {
return { value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array() };
return { value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(0) };
},

toJSON(message: BytesValue): unknown {
const obj: any = {};
message.value !== undefined &&
(obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array()));
(obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array(0)));
return obj;
},

Expand All @@ -594,7 +594,7 @@ export const BytesValue = {

fromPartial<I extends Exact<DeepPartial<BytesValue>, I>>(object: I): BytesValue {
const message = createBaseBytesValue();
message.value = object.value ?? new Uint8Array();
message.value = object.value ?? new Uint8Array(0);
return message;
},
};
Expand Down
8 changes: 4 additions & 4 deletions integration/simple-optionals/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ export const StringValue = {
};

function createBaseBytesValue(): BytesValue {
return { value: new Uint8Array() };
return { value: new Uint8Array(0) };
}

export const BytesValue = {
Expand Down Expand Up @@ -578,13 +578,13 @@ export const BytesValue = {
},

fromJSON(object: any): BytesValue {
return { value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array() };
return { value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(0) };
},

toJSON(message: BytesValue): unknown {
const obj: any = {};
message.value !== undefined &&
(obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array()));
(obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array(0)));
return obj;
},

Expand All @@ -594,7 +594,7 @@ export const BytesValue = {

fromPartial<I extends Exact<DeepPartial<BytesValue>, I>>(object: I): BytesValue {
const message = createBaseBytesValue();
message.value = object.value ?? new Uint8Array();
message.value = object.value ?? new Uint8Array(0);
return message;
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ export const StringValue = {
};

function createBaseBytesValue(): BytesValue {
return { value: new Uint8Array() };
return { value: new Uint8Array(0) };
}

export const BytesValue = {
Expand Down Expand Up @@ -578,13 +578,13 @@ export const BytesValue = {
},

fromJSON(object: any): BytesValue {
return { value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array() };
return { value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(0) };
},

toJSON(message: BytesValue): unknown {
const obj: any = {};
message.value !== undefined &&
(obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array()));
(obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array(0)));
return obj;
},

Expand All @@ -594,7 +594,7 @@ export const BytesValue = {

fromPartial<I extends Exact<DeepPartial<BytesValue>, I>>(object: I): BytesValue {
const message = Object.create(createBaseBytesValue()) as BytesValue;
message.value = object.value ?? new Uint8Array();
message.value = object.value ?? new Uint8Array(0);
return message;
},
};
Expand Down
Loading

0 comments on commit 6280677

Please sign in to comment.