@snap/camera-kit
Version:
Camera Kit Web
170 lines • 6.4 kB
JavaScript
import Long from "long";
import _m0 from "protobufjs/minimal";
import { Timestamp } from "../../google/protobuf/timestamp";
export const protobufPackage = "snapchat.cdp.cof";
function createBaseBenchmarkValue() {
return { intValue: undefined, longValue: undefined, boolValue: undefined, floatValue: undefined };
}
export const BenchmarkValue = {
encode(message, writer = _m0.Writer.create()) {
if (message.intValue !== undefined) {
writer.uint32(8).int32(message.intValue);
}
if (message.longValue !== undefined) {
writer.uint32(16).int64(message.longValue);
}
if (message.boolValue !== undefined) {
writer.uint32(24).bool(message.boolValue);
}
if (message.floatValue !== undefined) {
writer.uint32(37).float(message.floatValue);
}
return writer;
},
decode(input, length) {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseBenchmarkValue();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.intValue = reader.int32();
break;
case 2:
message.longValue = longToString(reader.int64());
break;
case 3:
message.boolValue = reader.bool();
break;
case 4:
message.floatValue = reader.float();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromPartial(object) {
var _a, _b, _c, _d;
const message = createBaseBenchmarkValue();
message.intValue = (_a = object.intValue) !== null && _a !== void 0 ? _a : undefined;
message.longValue = (_b = object.longValue) !== null && _b !== void 0 ? _b : undefined;
message.boolValue = (_c = object.boolValue) !== null && _c !== void 0 ? _c : undefined;
message.floatValue = (_d = object.floatValue) !== null && _d !== void 0 ? _d : undefined;
return message;
},
};
function createBaseBenchmarkRequest() {
return { benchmarkNames: [], expirationTimestamp: undefined };
}
export const BenchmarkRequest = {
encode(message, writer = _m0.Writer.create()) {
writer.uint32(10).fork();
for (const v of message.benchmarkNames) {
writer.int32(v);
}
writer.ldelim();
if (message.expirationTimestamp !== undefined) {
Timestamp.encode(toTimestamp(message.expirationTimestamp), writer.uint32(18).fork()).ldelim();
}
return writer;
},
decode(input, length) {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseBenchmarkRequest();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if ((tag & 7) === 2) {
const end2 = reader.uint32() + reader.pos;
while (reader.pos < end2) {
message.benchmarkNames.push(reader.int32());
}
}
else {
message.benchmarkNames.push(reader.int32());
}
break;
case 2:
message.expirationTimestamp = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromPartial(object) {
var _a, _b;
const message = createBaseBenchmarkRequest();
message.benchmarkNames = ((_a = object.benchmarkNames) === null || _a === void 0 ? void 0 : _a.map((e) => e)) || [];
message.expirationTimestamp = (_b = object.expirationTimestamp) !== null && _b !== void 0 ? _b : undefined;
return message;
},
};
function createBaseBenchmarkResult() {
return { name: 0, value: undefined };
}
export const BenchmarkResult = {
encode(message, writer = _m0.Writer.create()) {
if (message.name !== 0) {
writer.uint32(8).int32(message.name);
}
if (message.value !== undefined) {
BenchmarkValue.encode(message.value, writer.uint32(18).fork()).ldelim();
}
return writer;
},
decode(input, length) {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseBenchmarkResult();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.name = reader.int32();
break;
case 2:
message.value = BenchmarkValue.decode(reader, reader.uint32());
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromPartial(object) {
var _a;
const message = createBaseBenchmarkResult();
message.name = (_a = object.name) !== null && _a !== void 0 ? _a : 0;
message.value =
object.value !== undefined && object.value !== null ? BenchmarkValue.fromPartial(object.value) : undefined;
return message;
},
};
function toTimestamp(date) {
const seconds = Math.trunc(date.getTime() / 1000).toString();
const nanos = (date.getTime() % 1000) * 1000000;
return { seconds, nanos };
}
function fromTimestamp(t) {
let millis = Number(t.seconds) * 1000;
millis += t.nanos / 1000000;
return new Date(millis);
}
function longToString(long) {
return long.toString();
}
if (_m0.util.Long !== Long) {
_m0.util.Long = Long;
_m0.configure();
}
//# sourceMappingURL=benchmark.js.map