UNPKG

ardunno-cli

Version:
220 lines (219 loc) 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.Port_PropertiesEntry = exports.Port = void 0; /* eslint-disable */ const minimal_1 = __importDefault(require("protobufjs/minimal")); function createBasePort() { return { address: '', label: '', protocol: '', protocolLabel: '', properties: {}, hardwareId: '', }; } exports.Port = { encode(message, writer = minimal_1.default.Writer.create()) { if (message.address !== '') { writer.uint32(10).string(message.address); } if (message.label !== '') { writer.uint32(18).string(message.label); } if (message.protocol !== '') { writer.uint32(26).string(message.protocol); } if (message.protocolLabel !== '') { writer.uint32(34).string(message.protocolLabel); } Object.entries(message.properties).forEach(([key, value]) => { exports.Port_PropertiesEntry.encode({ key: key, value }, writer.uint32(42).fork()).ldelim(); }); if (message.hardwareId !== '') { writer.uint32(50).string(message.hardwareId); } return writer; }, decode(input, length) { const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBasePort(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: if (tag !== 10) { break; } message.address = reader.string(); continue; case 2: if (tag !== 18) { break; } message.label = reader.string(); continue; case 3: if (tag !== 26) { break; } message.protocol = reader.string(); continue; case 4: if (tag !== 34) { break; } message.protocolLabel = reader.string(); continue; case 5: if (tag !== 42) { break; } const entry5 = exports.Port_PropertiesEntry.decode(reader, reader.uint32()); if (entry5.value !== undefined) { message.properties[entry5.key] = entry5.value; } continue; case 6: if (tag !== 50) { break; } message.hardwareId = reader.string(); continue; } if ((tag & 7) === 4 || tag === 0) { break; } reader.skipType(tag & 7); } return message; }, fromJSON(object) { return { address: isSet(object.address) ? String(object.address) : '', label: isSet(object.label) ? String(object.label) : '', protocol: isSet(object.protocol) ? String(object.protocol) : '', protocolLabel: isSet(object.protocolLabel) ? String(object.protocolLabel) : '', properties: isObject(object.properties) ? Object.entries(object.properties).reduce((acc, [key, value]) => { acc[key] = String(value); return acc; }, {}) : {}, hardwareId: isSet(object.hardwareId) ? String(object.hardwareId) : '', }; }, toJSON(message) { const obj = {}; message.address !== undefined && (obj.address = message.address); message.label !== undefined && (obj.label = message.label); message.protocol !== undefined && (obj.protocol = message.protocol); message.protocolLabel !== undefined && (obj.protocolLabel = message.protocolLabel); obj.properties = {}; if (message.properties) { Object.entries(message.properties).forEach(([k, v]) => { obj.properties[k] = v; }); } message.hardwareId !== undefined && (obj.hardwareId = message.hardwareId); return obj; }, create(base) { return exports.Port.fromPartial(base !== null && base !== void 0 ? base : {}); }, fromPartial(object) { var _a, _b, _c, _d, _e, _f; const message = createBasePort(); message.address = (_a = object.address) !== null && _a !== void 0 ? _a : ''; message.label = (_b = object.label) !== null && _b !== void 0 ? _b : ''; message.protocol = (_c = object.protocol) !== null && _c !== void 0 ? _c : ''; message.protocolLabel = (_d = object.protocolLabel) !== null && _d !== void 0 ? _d : ''; message.properties = Object.entries((_e = object.properties) !== null && _e !== void 0 ? _e : {}).reduce((acc, [key, value]) => { if (value !== undefined) { acc[key] = String(value); } return acc; }, {}); message.hardwareId = (_f = object.hardwareId) !== null && _f !== void 0 ? _f : ''; return message; }, }; function createBasePort_PropertiesEntry() { return { key: '', value: '' }; } exports.Port_PropertiesEntry = { encode(message, writer = minimal_1.default.Writer.create()) { if (message.key !== '') { writer.uint32(10).string(message.key); } if (message.value !== '') { writer.uint32(18).string(message.value); } return writer; }, decode(input, length) { const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBasePort_PropertiesEntry(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: if (tag !== 10) { break; } message.key = reader.string(); continue; case 2: if (tag !== 18) { break; } message.value = reader.string(); continue; } if ((tag & 7) === 4 || tag === 0) { break; } reader.skipType(tag & 7); } return message; }, fromJSON(object) { return { key: isSet(object.key) ? String(object.key) : '', value: isSet(object.value) ? String(object.value) : '', }; }, toJSON(message) { const obj = {}; message.key !== undefined && (obj.key = message.key); message.value !== undefined && (obj.value = message.value); return obj; }, create(base) { return exports.Port_PropertiesEntry.fromPartial(base !== null && base !== void 0 ? base : {}); }, fromPartial(object) { var _a, _b; const message = createBasePort_PropertiesEntry(); message.key = (_a = object.key) !== null && _a !== void 0 ? _a : ''; message.value = (_b = object.value) !== null && _b !== void 0 ? _b : ''; return message; }, }; function isObject(value) { return typeof value === 'object' && value !== null; } function isSet(value) { return value !== null && value !== undefined; }