UNPKG

spot-sdk-ts

Version:

TypeScript bindings based on protobufs (proto3) provided by Boston Dynamics

213 lines 8.09 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Parameter = exports.protobufPackage = void 0; /* eslint-disable */ const timestamp_1 = require("../../google/protobuf/timestamp"); const long_1 = __importDefault(require("long")); const duration_1 = require("../../google/protobuf/duration"); const minimal_1 = __importDefault(require("protobufjs/minimal")); exports.protobufPackage = "bosdyn.api"; function createBaseParameter() { return { label: "", units: "", intValue: undefined, floatValue: undefined, timestamp: undefined, duration: undefined, stringValue: undefined, boolValue: undefined, uintValue: undefined, notes: "", }; } exports.Parameter = { encode(message, writer = minimal_1.default.Writer.create()) { if (message.label !== "") { writer.uint32(10).string(message.label); } if (message.units !== "") { writer.uint32(18).string(message.units); } if (message.intValue !== undefined) { writer.uint32(24).int64(message.intValue); } if (message.floatValue !== undefined) { writer.uint32(33).double(message.floatValue); } if (message.timestamp !== undefined) { timestamp_1.Timestamp.encode(toTimestamp(message.timestamp), writer.uint32(42).fork()).ldelim(); } if (message.duration !== undefined) { duration_1.Duration.encode(message.duration, writer.uint32(50).fork()).ldelim(); } if (message.stringValue !== undefined) { writer.uint32(58).string(message.stringValue); } if (message.boolValue !== undefined) { writer.uint32(64).bool(message.boolValue); } if (message.uintValue !== undefined) { writer.uint32(80).uint64(message.uintValue); } if (message.notes !== "") { writer.uint32(74).string(message.notes); } return writer; }, decode(input, length) { const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseParameter(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.label = reader.string(); break; case 2: message.units = reader.string(); break; case 3: message.intValue = longToNumber(reader.int64()); break; case 4: message.floatValue = reader.double(); break; case 5: message.timestamp = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32())); break; case 6: message.duration = duration_1.Duration.decode(reader, reader.uint32()); break; case 7: message.stringValue = reader.string(); break; case 8: message.boolValue = reader.bool(); break; case 10: message.uintValue = longToNumber(reader.uint64()); break; case 9: message.notes = reader.string(); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object) { return { label: isSet(object.label) ? String(object.label) : "", units: isSet(object.units) ? String(object.units) : "", intValue: isSet(object.intValue) ? Number(object.intValue) : undefined, floatValue: isSet(object.floatValue) ? Number(object.floatValue) : undefined, timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined, duration: isSet(object.duration) ? duration_1.Duration.fromJSON(object.duration) : undefined, stringValue: isSet(object.stringValue) ? String(object.stringValue) : undefined, boolValue: isSet(object.boolValue) ? Boolean(object.boolValue) : undefined, uintValue: isSet(object.uintValue) ? Number(object.uintValue) : undefined, notes: isSet(object.notes) ? String(object.notes) : "", }; }, toJSON(message) { const obj = {}; message.label !== undefined && (obj.label = message.label); message.units !== undefined && (obj.units = message.units); message.intValue !== undefined && (obj.intValue = Math.round(message.intValue)); message.floatValue !== undefined && (obj.floatValue = message.floatValue); message.timestamp !== undefined && (obj.timestamp = message.timestamp.toISOString()); message.duration !== undefined && (obj.duration = message.duration ? duration_1.Duration.toJSON(message.duration) : undefined); message.stringValue !== undefined && (obj.stringValue = message.stringValue); message.boolValue !== undefined && (obj.boolValue = message.boolValue); message.uintValue !== undefined && (obj.uintValue = Math.round(message.uintValue)); message.notes !== undefined && (obj.notes = message.notes); return obj; }, fromPartial(object) { const message = createBaseParameter(); message.label = object.label ?? ""; message.units = object.units ?? ""; message.intValue = object.intValue ?? undefined; message.floatValue = object.floatValue ?? undefined; message.timestamp = object.timestamp ?? undefined; message.duration = object.duration !== undefined && object.duration !== null ? duration_1.Duration.fromPartial(object.duration) : undefined; message.stringValue = object.stringValue ?? undefined; message.boolValue = object.boolValue ?? undefined; message.uintValue = object.uintValue ?? undefined; message.notes = object.notes ?? ""; return message; }, }; var globalThis = (() => { if (typeof globalThis !== "undefined") return globalThis; if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; if (typeof global !== "undefined") return global; throw "Unable to locate global object"; })(); function toTimestamp(date) { const seconds = date.getTime() / 1000; const nanos = (date.getTime() % 1000) * 1000000; return { seconds, nanos }; } function fromTimestamp(t) { let millis = t.seconds * 1000; millis += t.nanos / 1000000; return new Date(millis); } function fromJsonTimestamp(o) { if (o instanceof Date) { return o; } else if (typeof o === "string") { return new Date(o); } else { return fromTimestamp(timestamp_1.Timestamp.fromJSON(o)); } } function longToNumber(long) { if (long.gt(Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } if (minimal_1.default.util.Long !== long_1.default) { minimal_1.default.util.Long = long_1.default; minimal_1.default.configure(); } function isSet(value) { return value !== null && value !== undefined; } //# sourceMappingURL=parameter.js.map