UNPKG

@reactivemarkets/switchboard-api

Version:

Generated api for Reactive Markets Switchboard network

126 lines (125 loc) 6.37 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); }; var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { if (kind === "m") throw new TypeError("Private method is not writable"); if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; }; var _MarketDataSnapshot_account, _MarketDataSnapshot_quoteId, _MarketDataSnapshot_symbol, _MarketDataSnapshot_tenor, _MarketDataSnapshot_venue; Object.defineProperty(exports, "__esModule", { value: true }); exports.MarketDataSnapshot = void 0; const flatbuffers = __importStar(require("flatbuffers")); const MarketDataSnapshot_generated_1 = require("./MarketDataSnapshot_generated"); // Auto-generated. From MarketDataSnapshot_generated.ts:account() const accountOffset = 6; const textEncoder = new TextEncoder(); const spaceCharacter = textEncoder.encode(" ")[0]; class MarketDataSnapshot extends MarketDataSnapshot_generated_1.MarketDataSnapshot { constructor() { super(...arguments); _MarketDataSnapshot_account.set(this, void 0); _MarketDataSnapshot_quoteId.set(this, void 0); _MarketDataSnapshot_symbol.set(this, void 0); _MarketDataSnapshot_tenor.set(this, void 0); _MarketDataSnapshot_venue.set(this, void 0); } account(optionalEncoding) { var _a, _b; if (optionalEncoding !== undefined) { const account = super.account(optionalEncoding); if (!(account instanceof Uint8Array)) { return account; } // Remove trailing spaces let end = account.length; while (end > 0 && account[end - 1] === spaceCharacter) { end--; } return account.subarray(0, end); } if (__classPrivateFieldGet(this, _MarketDataSnapshot_account, "f") === undefined) { __classPrivateFieldSet(this, _MarketDataSnapshot_account, (_b = (_a = super.account()) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : null, "f"); } return __classPrivateFieldGet(this, _MarketDataSnapshot_account, "f"); } quoteId(optionalEncoding) { if (optionalEncoding !== undefined) { return super.quoteId(optionalEncoding); } if (__classPrivateFieldGet(this, _MarketDataSnapshot_quoteId, "f") === undefined) { __classPrivateFieldSet(this, _MarketDataSnapshot_quoteId, super.quoteId(), "f"); } return __classPrivateFieldGet(this, _MarketDataSnapshot_quoteId, "f"); } /** * Replaces account within the fbs message. * @param account The new account symbol. */ replaceAccount(account) { let offset = this.bb.__offset(this.bb_pos, accountOffset); offset += this.bb_pos; offset += this.bb.readInt32(offset); offset += flatbuffers.SIZEOF_INT; const message = this.bb.bytes(); for (const byte of textEncoder.encode(account)) { message[offset++] = byte; } } symbol(optionalEncoding) { if (optionalEncoding !== undefined) { return super.symbol(optionalEncoding); } if (__classPrivateFieldGet(this, _MarketDataSnapshot_symbol, "f") === undefined) { __classPrivateFieldSet(this, _MarketDataSnapshot_symbol, super.symbol(), "f"); } return __classPrivateFieldGet(this, _MarketDataSnapshot_symbol, "f"); } tenor(optionalEncoding) { if (optionalEncoding !== undefined) { return super.tenor(optionalEncoding); } if (__classPrivateFieldGet(this, _MarketDataSnapshot_tenor, "f") === undefined) { __classPrivateFieldSet(this, _MarketDataSnapshot_tenor, super.tenor(), "f"); } return __classPrivateFieldGet(this, _MarketDataSnapshot_tenor, "f"); } venue(optionalEncoding) { if (optionalEncoding !== undefined) { return super.venue(optionalEncoding); } if (__classPrivateFieldGet(this, _MarketDataSnapshot_venue, "f") === undefined) { __classPrivateFieldSet(this, _MarketDataSnapshot_venue, super.venue(), "f"); } return __classPrivateFieldGet(this, _MarketDataSnapshot_venue, "f"); } } exports.MarketDataSnapshot = MarketDataSnapshot; _MarketDataSnapshot_account = new WeakMap(), _MarketDataSnapshot_quoteId = new WeakMap(), _MarketDataSnapshot_symbol = new WeakMap(), _MarketDataSnapshot_tenor = new WeakMap(), _MarketDataSnapshot_venue = new WeakMap();