@htdangkhoa/google-ads
Version:
Google Ads API client for Node.js
86 lines (85 loc) • 2.81 kB
JavaScript
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.181.2
// protoc v3.21.12
// source: google/protobuf/duration.proto
/* eslint-disable */
import Long from "long";
import _m0 from "protobufjs/minimal.js";
function createBaseDuration() {
return { seconds: "0", nanos: 0 };
}
export const Duration = {
encode(message, writer = _m0.Writer.create()) {
if (message.seconds !== undefined && message.seconds !== "0") {
writer.uint32(8).int64(message.seconds);
}
if (message.nanos !== undefined && message.nanos !== 0) {
writer.uint32(16).int32(message.nanos);
}
return writer;
},
decode(input, length) {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseDuration();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 8) {
break;
}
message.seconds = longToString(reader.int64());
continue;
case 2:
if (tag !== 16) {
break;
}
message.nanos = reader.int32();
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object) {
return {
seconds: isSet(object.seconds) ? globalThis.String(object.seconds) : "0",
nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0,
};
},
toJSON(message) {
const obj = {};
if (message.seconds !== undefined && message.seconds !== "0") {
obj.seconds = message.seconds;
}
if (message.nanos !== undefined && message.nanos !== 0) {
obj.nanos = Math.round(message.nanos);
}
return obj;
},
create(base) {
return Duration.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a, _b;
const message = createBaseDuration();
message.seconds = (_a = object.seconds) !== null && _a !== void 0 ? _a : "0";
message.nanos = (_b = object.nanos) !== null && _b !== void 0 ? _b : 0;
return message;
},
};
function longToString(long) {
return long.toString();
}
if (_m0.util.Long !== Long) {
_m0.util.Long = Long;
_m0.configure();
}
function isSet(value) {
return value !== null && value !== undefined;
}