UNPKG

diffusion

Version:

Diffusion JavaScript client

65 lines (64 loc) 2.7 kB
"use strict"; /** * @module Services.FetchJMXValues */ var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.MBeanValuesSerialiser = exports.MBeanValuesSerialiserClass = void 0; var consts_1 = require("./../../cbor/consts"); var decoder_1 = require("./../../cbor/decoder"); var encoder_1 = require("./../../cbor/encoder"); var Codec = require("./../../io/codec"); var serialiser_1 = require("./../../serialisers/serialiser"); var encoder = new encoder_1.Encoder(); /** * Serialiser for {@link MBeanValues} */ var MBeanValuesSerialiserClass = /** @class */ (function (_super) { __extends(MBeanValuesSerialiserClass, _super); function MBeanValuesSerialiserClass() { return _super !== null && _super.apply(this, arguments) || this; } /** * Read a {@link MBeanValues} from the stream * * @param bis the input stream * @return the {@link MBeanValues} that was read */ MBeanValuesSerialiserClass.prototype.read = function (bis) { var buffer = Codec.readBytes(bis); var decoder = new decoder_1.Decoder(buffer); var parsed = decoder.nextValueExpecting(function (type) { return type === consts_1.types.MAP; }); return parsed; // there must be a better way to apply this constraint on the parsed value }; /** * Write a {@link MBeanValues} to the stream * * @param bos the output stream * @param value the {@link MBeanValues} to be written */ MBeanValuesSerialiserClass.prototype.write = function (bos, value) { encoder.encode(value); Codec.writeBytes(bos, encoder.flush()); }; return MBeanValuesSerialiserClass; }(serialiser_1.AbstractSerialiser)); exports.MBeanValuesSerialiserClass = MBeanValuesSerialiserClass; /** * The singleton */ // eslint-disable-next-line @typescript-eslint/naming-convention exports.MBeanValuesSerialiser = new MBeanValuesSerialiserClass();