UNPKG

nerdbank-streams

Version:
40 lines 1.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FrameHeader = void 0; const Utilities_1 = require("./Utilities"); class FrameHeader { /** * Initializes a new instance of the `FrameHeader` class. * @param code The kind of frame this is. * @param channel The channel that this frame refers to or carries a payload for. */ constructor(code, channel) { this.code = code; if (channel) { (0, Utilities_1.requireInteger)('channelId', channel.id, 4, 'signed'); } this.code = code; this._channel = channel; } /** The channel that this frame refers to or carries a payload for. */ get channel() { return this._channel; } /** * Gets the channel that this frame refers to or carries a payload for. */ get requiredChannel() { if (this.channel) { return this.channel; } throw new Error('Expected channel not present in frame header.'); } /** Changes the channel.source property to reflect the opposite perspective (i.e. remote and local values switch). */ flipChannelPerspective() { if (this._channel) { this._channel = { id: this._channel.id, source: this._channel.source * -1 }; } } } exports.FrameHeader = FrameHeader; //# sourceMappingURL=FrameHeader.js.map